Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following yaml file provides a sample configuration which uses telegraf and docker as input plugins and influx and influx_v2 as output plugins - telegraf.yaml

For the docker input plugin to work we must mount /var/run/docker.sock into our container, we also need to set the security context for the container. To do this follow the instructions below.

Code Block
languagebash
titleSecurity Context setup
# Setup the telegraf user
sudo useradd -g docker telegraf
sudo passwd telegraf

id telegraf

uid=1001(telegraf) gid=1001(docker) groups=1001(docker)

Log into the container and see what group docker.sock is assigned to
/ $ ls -l /var/run/docker.sock
srw-rw----    1 root     ping             0 Mar 16 07:35 /var/run/docker.sock
# Get the id of the group
/ $ getent group ping
ping:x:999
# We now have the 3 ids we need for the security context
      securityContext:
        runAsUser: 1001
        runAsGroup: 1001
        fsGroup: 999

Change these values in your container if they are different from above.telegraf.yaml


Our metrics are being collected into the telegraf bucket.

...