influxdata/telegraf

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

Open

#7750 aperta il 26 giu 2020

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)Go (4161 fork)batch import
feature requesthelp wantedsize/l

Metriche repository

Star
 (9892 star)
Metriche merge PR
 (Merge medio 2g 12h) (136 PR mergiate in 30 g)

Descrizione

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

Guida contributor