I created a new template.json file and defined the path to it in the output block of the elasticsearch logstash.yml configuration file:
stdout { codec => json_lines } elasticsearch { "hosts" => ["ip:port"] "index" => "name-of-index-%{+dd.MM.YYYY}" template => "/{path-to-logstash-folder}/templates/your-template.json" template_overwrite => true manage_template => false }
document_type for Elastic I specified in the input block of the logstash.yml configuration file:
input { file { path => "/your-path-to-directory/*.log" type => "name-of-type" } }
There is a template.json file
{ "name-of-index": { "order": 0, "version": 50001, "template": "name-of-index-*", "settings": { "index": { "refresh_interval": "5s" } }, "mappings": { "_default_": { "dynamic_templates": [ { "message_field": { "path_match": "message", "mapping": { "norms": false, "type": "text" }, "match_mapping_type": "string" } }, { "string_fields": { "mapping": { "norms": false, "type": "text", "fields": { "keyword": { "type": "keyword" } } }, "match_mapping_type": "string", "match": "*" } } ], "_all": { "norms": false, "enabled": true }, "properties": { "@timestamp": { "include_in_all": false, "type": "date" }, "geoip": { "dynamic": true, "properties": { "ip": { "type": "ip" }, "latitude": { "type": "half_float" }, "location": { "type": "geo_point" }, "longitude": { "type": "half_float" } } }, "@version": { "include_in_all": false, "type": "keyword" } } } }, "aliases": {} } }
source share