30/04/2016

Use different source or destination in one config file - Telegraf.

Data and metrics are my favorite parts, that's why I really love InfluxDB and its stack (TICK stack which is: Telegraf, InfluxDB, Chronograf, and Kapacitor) ... but actually I like to use Grafana instead Chronograf.

One of these component is Telegraf, which is a nice daemon like collectd with a lot of extensions.
Telegraf is an open source agent written in Go for collecting metrics and data on the system it’s running on or from other services. Telegraf then writes the data to InfluxDB in the correct format.
Sometimes you need Telegraf to send metrics to more than one database, and instead using multi configuration files, you can do this by filler the data.

Telegraf has many measurement filters that allow you to pass or drop specific metrics to specific database within the same configuration file.

In this example, you will pass all PostgreSQL metrics to specific database (which is InfluxDB database called "postgres"). Note "namepass" at the end of example.

Remember, if you have another output source (e.g. another InfluxDB for rest of system metrics), you still need to filter this value by using "namedrop".

The best practice here is to don't use "catch-all" database, and specify metrics that you need to sent each database using "namepass".

###############################################################################
#                                  OUTPUTS                                    #
###############################################################################

# Configuration for influxdb server to send metrics to
[[outputs.influxdb]]
  # The full HTTP or UDP endpoint URL for your InfluxDB instance.
  # Multiple urls can be specified but it is assumed that they are part of the same
  # cluster, this means that only ONE of the urls will be written to each interval.
  urls = ["http://127.0.0.1:8086"] # required
  # The target database for metrics (telegraf will create it if not exists)
  database = "postgres" # required
  # Precision of writes, valid values are n, u, ms, s, m, and h
  # note: using second precision greatly helps InfluxDB compression
  precision = "s"

  # Connection timeout (for the connection with InfluxDB), formatted as a string.
  # If not provided, will default to 0 (no timeout)
  timeout = "30s"
  username = "INFLUX_USER"
  password = "INFLUX_PASS"
  # Set the user agent for HTTP POSTs (can be useful for log differentiation)
  # user_agent = "telegraf"
  # Set UDP payload size, defaults to InfluxDB UDP Client default (512 bytes)
  # udp_payload = 512
 
  # This metrics only will go to "postgres" database.
  namepass = ["postgresql*"]
So now, all metrics that start with "postgresql" will go to "postgres" (but if you didn't filter this name in other output sources they also will go to other defined databases as well).
Powered by Blogger.

Hello, my name is Ahmed AbouZaid and this is my "lite" technical blog!

I'm a passionate DevOps, Linux system administrator, RedHat Certified Engineer (RHCE), AWS SysOps/Solutions Architect, Free/Open source geek, author, interested in environment, calligraphy, and I believe that “Details Matter”!

Automation, data, and metrics are my preferred areas. I have a built-in monitoring chip, and too lazy to do anything manually :D

Popular Posts