Building Dashboards with Grafana

Project status: complete


Note: see this other page to find out how to install Docker on Ubuntu.

Docker Compose File

I use docker-compose to run the 3 containers, here is the current docker-compose.yml file (check the Github repository for future changes):

Note: I built a custom-build Docker image for Telegraf because the official one does not include the required SNMP tools.

version: '2'

    image: "influxdb"
      - "8086:8086"
      - "8083:8083"
      - ./data/influxdb:/var/lib/influxdb

    image: "nuntz/telegraf-snmp"
      - ./data/telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro

    image: "grafana/grafana"
      - "3000:3000"
      - ./data/grafana/lib:/var/lib/grafana
      - ./data/grafana/log:/var/log/grafana
      - ./data/grafana/etc:/etc/grafana

Each container has one or more volumes defined for data persistency, in ./data/:

The current directory must contain a data directory, and two configuration must be created before running the containers:

Running the Containers

The containers can be started using:

$ sudo docker-compose up

SNMP Configuration for Telegraf

Here is a sample section of the telegraf.conf file for a router (with IP address, used to collect interface metrics (based on this example configuration file):

  agents = [ "" ]
  version = 2
  community = "public"

    name = "hostname"
    oid = "."
    is_tag = true

  # IF-MIB::ifTable contains counters on input and output traffic as well as errors and discards.
    name = "interface"
    inherit_tags = [ "hostname" ]
    oid = "."

    # Interface tag - used to identify interface in metrics database
      name = "ifDescr"
      oid = "."
      is_tag = true

Creating Panel in Grafana

First, we need to setup the InfluxDB data source:

We can now create our dashboard:

Sample metric to poll interface usage:

SELECT derivative(mean("ifInOctets"), 10s) FROM "interface" WHERE "ifDescr" = 'eth0' AND $timeFilter GROUP BY time($interval) fill(null)