What Can The Telegraf Agent Do?

Well when it comes to monitoring, it covers all the basics you’ll probably ever encounter. For those who don’t know, the Telegraf agent is a monitoring agent that can be installed on servers (or any computer for that matter) to give you information on how the server is performing. The basics in this case are usage metrics for CPU, Memory, Network, Disk Space, Disk IO, etc.

But it’d be remiss to say this is what Telegraf is, because it can do so much more than that. Sure the common use case is probably just being used as an agent on servers to grab systemic metrics, but those who are only using it for this are really missing out.

Before I delve into some cool things Telegraf can be used for, you’ll need to know the basics of how Telegraf is configured. In simple terms, you specify your inputs and your outputs. Your inputs are what you want Telegraf to collect. If you’re using this to monitor a server, your inputs would likely be CPU, Memory, etc. Here’s a list of the currently available inputs in Telegraf (https://github.com/influxdata/telegraf/tree/master/plugins/inputs). Then your outputs are where to send the data that is collected from the inputs. Outputs are typically times series databases like Graphite or InfluxDB, but Telegraf doesn’t put reins on you if you wanted to send your data someplace else. For the most part, any mainstream platform or service that you could send data to has an output built into Telegraf already. Here’s a list of the currently available outputs in Telegraf (https://github.com/influxdata/telegraf/tree/master/plugins/outputs).

Cool Things Telegraf Can Do

If you looked at the inputs link above, you probably noticed that Telegraf has 200+ input plugins. With that being said, I’m only going to be highlighting the few that I’ve worked with and think can provide the most value to other engineers out there tasked with the responsibility of monitoring systems.

HTTP

Endpoint monitoring is a pretty common practice, and there’s plenty of expensive SaaS solutions out there that can do it for you. But if you’re looking to set something up yourself, Telegraf has a fairly robust endpoint monitoring plugin built into it (https://github.com/influxdata/telegraf/tree/master/plugins/inputs/http). It allows you to specify Headers you want sent with your request, the HTTP method (GET, POST, PUT), and the method body if you’re sending a POST or PUT request. If your endpoint has basic auth or OAuth2, you’re covered there too. This input also supports the use of a proxy and self signed certificates.

One of the things that I want to highlight with this input is where you can use it. A SaaS endpoint monitoring solution is just going to check the public endpoint of your site. Lets say you have 10 web servers running behind a load balancer for your site. You can setup Telegraf in the same network and monitor each web servers HTTP endpoint for issues, as well as the public endpoint of the site, giving you much more insight whenever issues arise.

HTTP_RESPONSE

The http_response input (https://github.com/influxdata/telegraf/tree/master/plugins/inputs/http_response) is very similar to the http input, but with the added feature that it can do a response string match. And not only can it do a response string match, it can do a regex match on the response. It doesn’t contain all of the bells and whistles as the http input with it lacking OAuth2 and proxy functionality. From what I can tell (and at the time of this writing), it supports all of the remaining features of the http input.

SNMP

This is somewhat of a specific use case (https://github.com/influxdata/telegraf/tree/master/plugins/inputs/snmp). Engineers who are dealing with networking infrastructure are the ones who could benefit the most from this input, as the SNMP protocol is primarily used in networking. Some on prem hardware have these nice interfaces and REST APIs, but there’s a lot that don’t, and they often expose that information using an ancient protocol called SNMP. This plugin is a ridiculously easy way of pulling that info out and sending it to your output of choice so you have insight into your networking hardware.

EXEC

The exec plugin (https://github.com/influxdata/telegraf/tree/master/plugins/inputs/exec) is a way for you to have your own custom input by calling a script that returns data. Let’s say you have a REST API that you want information from every minute. You can write a script that, when called, will query the API endpoint, sanitize the data into a format that Telegraf can read, and output it. You can then have Telegraf call this script every minute using the exec plugin to get that data, where it can then be sent to whatever output to want.

App Specific Inputs

There’s a lot of application specific plugins that would take a long time to go into, so instead I’m going to just list them here.

Moral of the story, if it’s popular and widely used, someone in the open source community probably built a plugin for it.

I highly recommend looking over the input plugins list if you got this far and haven’t looked at it yet. I’ll even put a link here to make it easy for you -> https://github.com/influxdata/telegraf/tree/master/plugins/inputs.

With a little set up (emphasis on little), Telegraf is capable of providing a state of the art monitoring set up for whatever your environment has. Whether you’re attempting to monitor servers, hardware, or commonly used software, Telegraf’s extensibility has made it a favorite among the open source community, also making it a favorite among the monitoring community.

Leave a Reply