Value Groups/Tags with the InfluxDB/Telegraf Data Source

Video Lecture

Value Groups/Tags with the InfluxDB/Telegraf Data Source Value Groups/Tags with the InfluxDB/Telegraf Data Source Value Groups/Tags with the InfluxDB/Telegraf Data Source

Description

Value groups/tags behave very differently depending on the Data Source used for the queries. This example is specific for when using the InfluxDB Data Source using Telegraf as the collector.

This example also takes Value groups/tags functionality further by adding a second custom input to the telegraf collector to help group an existing query that contains no useable information that could already be used for grouping.

This example is also specific to my infrastructure, so you will need to group and name your variables and adjust your queries depending on the specifics of your own infrastructure. This is just provided so there may be something that you can get a grasp on easier.

Value Groups/Tags with the InfluxDB/Telegraf Data Source

Custom Telegraf Input

[[inputs.exec]]
  commands = [
    "echo 'containers,group=web value=\"vethe531acc\"' ",
    "echo 'containers,group=web value=\"vetheb1c4f8\"' ",
    "echo 'containers,group=db value=\"vetha4cd00c\"' ",
    "echo 'containers,group=db value=\"vethc6a79ec\"' ",
    "echo 'containers,group=db value=\"vethda1e7e0\"' ",
    "echo 'containers,group=cache value=\"veth2059834\"' ",
    "echo 'containers,group=cache value=\"vethbdea195\"' ",
    "echo 'containers,group=cache value=\"vethd72d2fd\"' "
  ]
  timeout = "5s"
  data_format = "influx"

Interface Variables used in the Dashboard

Key Value More Info
Name interface
Type Query
Label Interface
Data Source InfluxDB
Query SHOW TAG VALUES FROM interface WITH KEY = "ifDescr" WHERE agent_host = '2coin.org' The main default query that creates all the values that appear in the drop down list.
Multi-Value True
Value Groups/Tags Enabled
Tags Query SHOW TAG VALUES FROM containers WITH KEY = "group" The query that creates all the group names that appear as coloured tags to the right of the drop down list.
Tag Values Query SELECT distinct("value") FROM "containers" WHERE ("group" = '$tag') The query, that when run, selects all the values in the drop down list.

Custom Tags

You can also add custom tags to your telegraf inputs manually. This helps if you have many InfluxDB data sources, and you want to segregate them further into there own regions or some other tag name that would be useful.

eg,

Add the global_tags option to one of your /etc/telegraf/telegraf.conf files.

# Global Agent Configuration
[agent]
  hostname = "127.0.0.1"
  flush_interval = "15s"
  interval = "15s"

[global_tags]
  region="us-east-1"

# Input Plugins
... etc

Test the telegraf conf is ok,

telegraf --test

If no errors detected then

sudo service telegraf restart

Now open the Grafana UI and explore your data source and you will now have a new option to filter where region = us-east-1 Telegraf global_tags String