influxdata/telegraf

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

Open

#7,750 opened on Jun 26, 2020

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Go (9,892 stars) (4,161 forks)batch import
feature requesthelp wantedsize/l

Description

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

Contributor guide

docker_log: Include/exclude containers by image name/container labels · influxdata/telegraf#7750 | Good First Issue