

You could also make changes to this file and re-import the template to Elastic, by issuing: 1| Delete the current template from Kibana DELETE /_template/filebeatĢ| Make FB regenerate and reimport the template filebeat setup -template Modifying FB Template By Editing /etc/filebeat/fields.ymlįB generates the template by parsing the file: /etc/filebeat/fields.yml You can also tell FB to not make filebeat template, and make sure you do it by yourself. If this option is set to “ true” ,whenever you restart Filebeat, your template will be overwritten by the default one.Ĥ| (Optional) Disable template creation by FB There is a setting in /etc/filebeat/filebeat.yml for this, which looks like this: : false curl -XPUT -H 'Content-Type: application/json' Make sure Filebeat won’t override the templateĪfter importing your custom template to override the default filebeat template, you should make sure Filebeat is not configured to overwrite templates. The command assumes your cluster is accessible on “localhost:9200”. Then, copy the file somewhere in filebeat dir, for example to “/etc/filebeat/filebeat.template”Ģ| Overwrite the template in ElasticSearch Now you can make whatever modifications you like to the filebeat.template file. Making custom template out of current FB template 1| Dump your current template filebeat export template > filebeat.template Sometimes there is a need to change field mappings, or default index settings in that template. You can see what mappings/definitions the template has, by executing the following in your Kibana Console: GET /_template/filebeat The template is called “filebeat” and applies to all “ filebeat-*” indexes created. Modifying Default Filebeat Template (when using ElasticSearch output)īy default, when you first run Filebeat it will try to create template with field mappings in your ElasticSearch cluster.

More information about using ‘indices:’ you can read here: This will send the logs to bad/good index based on the message content if it has BAD or GOOD in it.

Here is how you can make filebeat, send logs to a separate indexes based on the module name, the log comes from. I prefer each of my logs (by types) to produce it’s messages in a separate elastic index. This could become tedious for support and messy to navigate into. If you are using some of the modules, this is how the config should look like (the example is for the apache2.yml module): - module: apache2Ĥ| Finally, start again Filebeat systemctl start filebeat Generating Dynamic Index Names In Filebeat Index names based on Modules / Filesets usedīy default, filebeat will push all the data it reads (from log files) into the same elasticsearch index. Glob based paths.ģ.b| Add the ‘tail_files’ option to Filebeat module configuration # Paths that should be crawled and fetched.

# Change to true to enable this input configuration. If you are using Log definitions, it need to look something like this: - type: log If you don’t do this, the “tail” wont work and Filebeat will continue to read the log from the last position it has.ģ.a| Add the ‘ tail_files‘ option to your Log definition It is necessary to delete the registry, if you have started Filebeat before with (tail option not enabled). The right way of configuring log tailing is as follows:Ģ| Delete filebeat registry file rm -vf /var/lib/filebeat/registry That’s usefull when you have big log-files and you don’t want FileBeat to read all of them, but just the new events. The idea of ‘ tail‘ is to tell Filebeat read only new lines from a given log-file, not the whole file. This was one of the first things I wanted to make Filebeat do. Here I will share some of my experience with it. If you have made it through the initial filebeat installation, you may want to do some more interesting stuff with Filebeat. 2| Make FB regenerate and reimport the template.1| Delete the current template from Kibana.Modifying FB Template By Editing /etc/filebeat/fields.yml.4| (Optional) Disable template creation by FB.3| Make sure Filebeat won’t override the template.2| Overwrite the template in ElasticSearch.Making custom template out of current FB template.Modifying Default Filebeat Template (when using ElasticSearch output).Index names based on the log lines being read.Index names based on Modules / Filesets used.Generating Dynamic Index Names In Filebeat.
