简体   繁体   中英

Logstash kafka topic as part of elasticsearch indexname

I want to use kafka topic as part of es-indexname. Here is my example, but this does not work:

input {
  kafka {    
    ...
    decorate_events => true
  }
}

filter {    
  mutate {
    add_field => {"[@metadata][index]" => "[kafka][topic]"}
  }
}

output {
  elasticsearch {
    index => "kafka-%{[@metadata][index]}-%{+YYYY.MM.dd}"
    ...
  }
}

Can someone find the problem in this logstash.conf?

hello this is working config:

input {
  kafka {    
    ...
    decorate_events => true
  }
}

filter {    
  mutate {
    add_field => {"[@metadata][index]" => "%{[kafka][topic]}"}
  }
}

output {
  elasticsearch {
    index => "kafka-%{[@metadata][index]}-%{+YYYY.MM.dd}"
    ...
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM