我正在尝试在 k8s 集群上配置 filebeat 代理,以将所有日志从两个不同的路径发送到弹性:
我尝试编写配置文件,但日志仅从 /var/logs/containers/*.log 传递
这是完整的配置文件:
filebeat.autodiscover:
providers:
- type: kubernetes
hints.enabled: true
hints.default_config:
enabled: false
type: container
paths:
- /var/log/containers/*.log # CRI path
- /var/log/agents/*.log
output.elasticsearch:
protocol: http
hosts: ["elasticsearch:9200"]
compression_level: 1
indices:
- index: "agent-logs"
when:
contains:
log.file.path: "agents"
- index: "container-logs"
when:
contains:
log.file.path: "containers"
我也尝试了这个配置,但是当我运行这个配置时,我只得到代理日志:
filebeat.autodiscover:
providers:
- type: kubernetes
hints.enabled: true
hints.default_config:
enabled: false
type: container
paths:
- /var/log/containers/*.log
filebeat.inputs:
- type: filestream
id: agent-filestream
paths:
- "/var/log/agents/*.log"
output.elasticsearch:
protocol: http
hosts: ["elasticsearch:9200"]
compression_level: 1
indices:
- index: "container-logs"
when:
contains:
log.file.path: "containers"
- index: "agent-logs"
when:
contains:
log.file.path: "agents"
请帮忙! 谢谢你
我最终成功解决了这个问题, 这是正确的配置文件:
filebeat.autodiscover:
providers:
- type: kubernetes
hints.enabled: true
hints.default_config:
enabled: false
type: container
paths:
- /var/log/containers/*.log
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/agents/*.log
output.elasticsearch:
protocol: http
hosts: ["elasticsearch:9200"]
compression_level: 1
indices:
- index: "container-logs"
when:
contains:
log.file.path: "containers"
- index: "agent-logs"
when:
contains:
log.file.path: "agents"