2

I want to get the filename from the source value provided by filebeat.

output {
  if [type] == "wxnumber" {
    elasticsearch {
        hosts => "localhost:9200"
        sniffing => false
        manage_template => false
        index => "%{[source]}"
        document_type => "%{[@metadata][type]}"
    }
  }
}

The %{[source]} is usually like /aaa/bbb/ccc.log. How do I set the index to the ccc.log?

Necoras
  • 6,743
  • 3
  • 24
  • 45
microchao
  • 23
  • 5

1 Answers1

0

Maybe you could use the mutate in order to replace it with how your log file should be named:

if [%{[source]}] =~ /aaa/bbb/ccc.log {
  mutate {
     replace => ["%{[source]}]", "ccc.log"]
  }
}

This SO might be helpful!

Community
  • 1
  • 1
Kulasangar
  • 9,046
  • 5
  • 51
  • 82