Release H: Telegraf

Introduction

Telegraf is an agent for collecting, processing, aggregating, and writing metrics.

The telegrapf repository is available here: Telegraf Repository and contains a number of plugins which can be included in your telegraf.conf file.

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.

Security 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.


Our metrics are being collected into the telegraf bucket.

We can now see the visualizations in the influx dashboard we imported using the community templates : Community Templates

Note: You'll need to configure each cell so it's retrieving the docker metrics from the correct bucket, in this case telegraf.


Links

How to Write a Telegraf Plugin for Beginners

Execd Input Plugin

Getting Started with Apache Kafka and InfluxDB