Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker_log include only one label - even with a exclude * #6456

Open
farfeduc opened this issue Sep 27, 2019 · 2 comments
Open

docker_log include only one label - even with a exclude * #6456

farfeduc opened this issue Sep 27, 2019 · 2 comments

Comments

@farfeduc
Copy link

@farfeduc farfeduc commented Sep 27, 2019

Relevant telegraf.conf:

[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_jitter = "0s"
  precision = "ms"
  hostname = ""
  omit_hostname = true

[[inputs.docker_log]]
  docker_label_include = ['java-logs']
  docker_label_exclude = ['*']

[[outputs.socket_writer]]
  address = "tcp4://172.24.0.21:20002"
  data_format = "json"

System info:

Docker version : 1.03.2
Telegraf version : 1.12.2 deployed as a docker service with the docker.sock mapped as a volume.

Relevant docker-compose.yml

version: "3.7"
services:
  telegraf-java:
    image: telegraf:1.12.2
    deploy:
      mode: global
      restart_policy:
        condition: on-failure
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
    configs:
      - source: telegraf-config-java
        target: /etc/telegraf/telegraf.conf

configs:
  telegraf-config-java:
    external: true
    name: "config-telegraf-log-containers-java"

Steps to reproduce:

  1. Deploy Telegraf (change output for anything you like)
  2. Deploy a service with label : java-logs=true (added on service and container levels)
  3. Deploy another service with no labels.

Expected behavior:

Only get the logs of the container with the java-logs label.

Actual behavior:

I get the logs from all containers, none are excluded.

Additional info:

Currently the logs are sent to Fluentd tcp listener that will then parse with grok the relevant log messages. But I would like only my java labeled containers to be parsed. Not all the cluster containers logs.

@glinton
Copy link
Member

@glinton glinton commented Oct 31, 2019

According to the documentation for docker_label_exclude, listing labels does not exclude the collection of containers with that label, but instead is a list of "docker labels to include and exclude as tags".

I may be wrong, but I don't believe there are plans to change this behavior as it would break compatibility. You can use the container_name_[include|exclude] config options to selectively gather logs from specific containers.

@danielnelson
Copy link
Contributor

@danielnelson danielnelson commented Nov 5, 2019

Thats right, unlike container_name_include and container_state_include, this option does not control if the container is collected. This keeps consistency with the docker input.

I wonder if adding a container_label_include pair of options would make sense.

At any rate, let's clarify this is in the documentation what include/exclude means on these options.

@danielnelson danielnelson added this to the planned milestone Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.