influxdata/telegraf

docker_log: Include/exclude containers by image name/container labels

Open

#7,750 创建于 2020年6月26日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Go (4,161 fork)batch import
feature requesthelp wantedsize/l

仓库指标

Star
 (9,892 star)
PR 合并指标
 (平均合并 2天 12小时) (30 天内合并 136 个 PR)

描述

Currently the only way for docker_log select what containers to read logs from is via the container name and state. Could the docker_log plugin be amended to make it able to select containers by image name or container labels?

Our use-case is that we have a large number of microservices running the same image(though different versions), and I would like to always read the logs of every one of them (regardless of version), but not other services we have running. It would particularly be good to be able to add more microservices running this image in the future without having to add the container name for each of them to telegraf.conf, or add services whose logs aren't supposed to be collected without worrying that they'll get slurped too.

I imagine the configuration would be:

[[inputs.docker_log]] ... container_image_include = ["my-image-name"] container_image_exclude = []

Filtering by lables would also be OK. I see the Docker Engine API supports this directly (at least the "include" part), albeit then without globs.

container_label_include = ["com.company.collect_logs=true"] container_label_exclude = []

I see this was mentioned at https://github.com/influxdata/telegraf/issues/6456#issuecomment-550023271

贡献者指南