Skip to content

Instantly share code, notes, and snippets.

@oroce
Created June 3, 2014 07:34
Show Gist options
  • Save oroce/f42ac5d08086aa2e2d29 to your computer and use it in GitHub Desktop.
Save oroce/f42ac5d08086aa2e2d29 to your computer and use it in GitHub Desktop.
elastic-search.template
{
"template": "logstash-*",
"settings" : {
"index" : {
"store" : { "compress" : { "stored" : true, "tv": true } }
}
},
"mappings": {
"_default_": {
"_all": { "enabled": false },
"_source": { "compress": true },
"dynamic_templates": [
{
"string_template" : {
"match" : "*",
"mapping": { "type": "string", "index": "not_analyzed" },
"match_mapping_type" : "string"
}
}
],
"properties" : {
"@fields": { "type": "object", "dynamic": true, "path": "full" },
"@message" : { "type" : "string", "index" : "analyzed" },
"@source" : { "type" : "string", "index" : "not_analyzed" },
"@source_host" : { "type" : "string", "index" : "not_analyzed" },
"@source_path" : { "type" : "string", "index" : "not_analyzed" },
"tags": { "type": "string", "index" : "not_analyzed" },
"@timestamp" : { "type" : "date", "index" : "not_analyzed" },
"type" : { "type" : "string", "index" : "not_analyzed" },
"request_time": { "type": "float" },
"upstream_response_time": { "type": "float" },
"bytes": { "type": "long" },
"geoip":{
"properties":{
"area_code":{"type":"long"},
"city_name":{"type":"string", "index":"not_analyzed"},
"continent_code":{"type":"string"},
"coordinates":{"type":"string"},
"country_code2":{"type":"string"},
"country_code3":{"type":"string"},
"country_name":{"type":"string", "index":"not_analyzed"},
"dma_code":{"type":"long"},
"ip":{"type":"string"},
"latitude":{"type":"double"},
"longitude":{"type":"double"},
"postal_code":{"type":"string"},
"real_region_name":{"type":"string", "index":"not_analyzed"},
"region_name":{"type":"string", "index":"not_analyzed"},
"timezone":{"type":"string"}
}
}
}
}
}
}
npm install -g elasticdump
elasticdump --input=http://localhost:9200/logstash-`date +'%Y.%m.%d'` --output=dump_`date +'%Y.%m.%d'`.json
curl -XPUT 'http://localhost:9200/_template/template_logstash/' -d @elasticsearch-template.json
curl -XDELETE localhost:9200/logstash-`date +'%Y.%m.%d'`
elasticdump --output=http://localhost:9200/logstash-`date +'%Y.%m.%d'` --bulk=true --input=dump_`date +'%Y.%m.%d'`.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment