I am collecting logs from two different paths:
- /var/log/containers/*.log
- /var/log/agents/*.log
I wanted a that files from each of the paths will be sent to different indexes in elasticsearch. I tried to define the filebeat configuration as follow:
output.elasticsearch:
protocol: http
hosts: ["elasticsearch:9200"]
compression_level: 1
indices:
- index: "agent-logs"
when:
contains:
log.file.path: "/var/log/agents/*.log"
- index: "container-logs"
when:
contains:
log.file.path: "/var/log/containers/*.log"
I also tried:
output.elasticsearch:
protocol: http
hosts: ["elasticsearch:9200"]
compression_level: 1
indices:
- index: "agent-logs"
when.contains:
log.file.path: "/var/log/agents/*.log"
- index: "container-logs"
when.contains:
log.file.path: "/var/log/containers/*.log"
and:
output.elasticsearch:
protocol: http
hosts: ["elasticsearch:9200"]
compression_level: 1
indices:
- index: "agent-logs"
when.equals:
log.file.path: "/var/log/agents/*.log"
- index: "container-logs"
when.equals:
log.file.path: "/var/log/containers/*.log"
But nothing seems to be working. Please help!
thank you
TLDR;
equalsandcontainsdo not support glob patterns. You may want to look intoregexpinstead ? or another distinct value.Solution
This might work better: