Logstash sprintf formatting for elasticsearch output plugin not working

前端 未结 1 1371
感动是毒
感动是毒 2020-12-12 07:18

I am having trouble using sprintf to reference the event fields in the elasticsearch output plugin and I\'m not sure why. Below is the event received from Filebeat and sent

相关标签:
1条回答
  • 2020-12-12 07:54

    In Elasticsearch Output plugin docs:
    https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-manage_template

    Should you require support for other index names, or would like to change the mappings in the template in general, a custom template can be specified by setting template to the path of a template file.

    Setting manage_template to false disables this feature. If you require more control over template creation, (e.g. creating indices dynamically based on field names) you should set manage_template to false and use the REST API to apply your templates manually.

    By default, elasticsearch requires you to specify a custom template if using different index names other than logstash-%{+YYYY.MM.dd}. To disable, we need to include the manage_template => false key.

    So with this new set of info, the working config should be:

    output {
      elasticsearch {
        hosts => ["elasticsearch:9200"]
        index => "%{[fields][env]}-%{+yyyy.MM.dd}"
        manage_template => false
      }
      stdout { codec => rubydebug }
    }
    
    0 讨论(0)
提交回复
热议问题