Logstash cannot use docker metadata to build a dynamic index

I use filebeat to collect docker logs and add a label when the docker container starts.

- type: docker
  enabled: true
    - '*'  
  tail_files: true

The following configuration is made in logstash to build a dynamic index.

filter {
     json {
       source => "message"

output {
    elasticsearch {
        hosts => ["","",""]
        ssl => true
        cacert => "/etc/logstash/ssl/root.pem"
        index => "%{[container.labels.service]}-%{+YYYY.MM.dd}"

But I failed and got the following index


You should use [container][labels][service] and not [container.labels.service].

Try to change the index option in your output to this:

index => "%{[container][labels][service]}-%{+YYYY.MM.dd}"

I tried to follow your example, and I got the following results:


After many tests, I solved the problem, it needs to meet some conditions. Thank you very much for your help

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.