提问要多花一点心思哦

filebeat采集k8s日志labels错乱

Beats | 作者 stephenwang | 发布于2021年11月22日 | 阅读数:2008

使用filebeat采集k8s时发现 日志结构中lables会带上不属于当前pod的信息,如 我想采集ingress pod的日志 那么在日志结构中k8s元数据中发现Labels带上了 其他业务容器的标签,filebeat配置如下:
apiVersion: v1
kind: ConfigMap
metadata:
namespace: elastic
name: filebeat-config
labels:
app: filebeat
data:
filebeat.yml: |-
filebeat.autodiscover:
providers:
- type: kubernetes
hints.enabled: true
hints.default_config:
type: container
paths:
- /var/lib/docker/containers/*/*.log
appenders:
- type: config
config:
tail_files: true
close_removed: true
clean_removed: true

processors:
- drop_event:
when:
regexp:
message: "kube-probe"
when.or:
- and:
- regexp:
message: '^\d+\.\d+\.\d+\.\d+ '
- equals:
fileset.name: error
- and:
- not:
regexp:
message: '^\d+\.\d+\.\d+\.\d+ '
- equals:
fileset.name: access
- add_kubernetes_metadata:
in_cluster: true
matchers:
- logs_path:
logs_path: "/var/log/containers/*${data.kubernetes.container.id}.log"

output.kafka:
hosts: ['${KAFKA_HOST:kafka}:${KAFKA_PORT:9092}']
topic: 'k8s-logs-test'
partition.round_robin:
reachable_only: false

setup.ilm:
policy_file: /etc/indice-lifecycle.json
logging.level: error
logging.metrics.enable: false






已邀请:

stephenwang - 6666

赞同来自:

请看附件

要回复问题请先登录注册