Using Telegraf

Telegraf is an easy to set up and configure monitoring client for a variety of operating systems (Windows, Macos, Linux, Red Hat and CentOS) that has a Graphite output plugin.

Linux Systems

  • Download Telegraf and unzip it (see the telegraf docs for the most recent versions). Packages are generally installed at /etc/telegraf/.
    > wget https://dl.influxdata.com/telegraf/releases/telegraf_1.21.2-1_amd64.deb
    > sudo dpkg -i telegraf_1.21.2-1_amd64.deb​
  • Locate the configuration file at /etc/telegraf/telegraf.conf and open it in your preferred text editor, or a VIM shell. Inside the telegraf.conf file, navigate to the ‘Graphite’ section and make the following changes:
    • comment out the [[outputs.influxdb]] line
    • uncomment the [[outputs.graphite]] line
    • uncomment and edit the servers line to: servers = ["carbon.hostedgraphite.com:2003"]
    • uncomment and edit the prefix line to: prefix = "YOUR_API_KEY.telegraf"undefined
  • Save changes and start telegraf services: sudo service telegraf start or sudo systemctl start telegraf.
  • Within minutes, Telegraf will start sending metrics into your Hosted Graphite account (with the ‘telegraf’ prefix).
  • Additionally, you can ‘serve’ the telegraf.conf file which can be helpful for troubleshooting any configuration issues: telegraf --config telegraf.conf

Macos

  • Install telegraf: brew install telegraf. Packages are usually installed at /usr/local/etc/
  • Similar to the steps listed above, locate the configuration file and open it in your preferred text editor. Inside the telegraf.conf file, navigate to the ‘Graphite’ section and make the following changes:
    • comment out the [[outputs.influxdb]] line
    • uncomment the [[outputs.graphite]]
    • uncomment the [[outputs.graphite]]
    • uncomment and edit the ‘prefix’ line to: prefix = "YOUR_API_KEY.telegraf"
  • Restart telegraf: brew services restart telegraf. Metrics usually take about 3-5 minutes to appear in your Hosted Graphite account and will include the ‘telegraf’ prefix in the name.
  • Additionally, you can ‘serve’ the telegraf.conf file which can be helpful for troubleshooting any configuration issues: telegraf --config telegraf.conf
    • Note: the influxdb output is enabled by default in telegraf.conf. This will cause an error message that’s visible in the output when you ‘serve’ the conf file. To clear this error, navigate to the influxdb section and comment out the [[outputs.influxdb]] line.

Procstat Plugin - System Application Monitoring

In addition to sending system metrics, you can also use telegraf to send metrics from local processes using the Procstat input plugin. Processes can be selected using several methods (pidfile, exe, pattern, user, etc.), as seen in the Procstat docs. In the below example, we are using the ‘pattern’ method which can be used for most Linux and Macos systems. (For Windows, we recommend using the Performance Counters plugin which you can read more about in the win_perf_counters docs).

  • Navigate to the ‘procstat’ section of the telegraf.conf file and make the following changes:
    • uncomment the [[inputs.procstat]] line
    • add a new line underneath that contains the application name: pattern = 'App-name'
    • exapmles:
      [[inputs.procstat]]
      pattern = 'Docker'
      
      [[inputs.procstat]]
      pattern = 'mysqld'
      
      [[inputs.procstat]]
      pattern = 'Terminal'
      
      [[inputs.procstat]]
      pattern = 'Chrome'​
  • Save the file and restart telegraf services. You will quickly see new metric names appear in your Hosted Graphite account that include the ‘telegraf’ and ‘procstat’ prefixes.
  • Additionally, telegraf offers many other input plugins that can monitor a wide variety of services. Find useful plugins and configuration steps in the telegraf documentation.

Windows via Powershell

  1. Download Telegraf using the wget command (an alias for Invoke-Webrequest) and unzip it:
> wget https://dl.influxdata.com/telegraf/releases/telegraf-1.5.2_windows_amd64.zip -O telegraf-1.5.2_windows_amd64.zip
> Expand-Archive .\telegraf-1.5.2_windows_amd64.zip

Note: This is the current version as of March 2018. The link for the most up-to-date version can be found on the Telegraf downloads page.

  

  • Create a directory in Program Files, move the two Telegraf files into it, and change directory to the same location:
> mkdir 'C:\Program Files\Telegraf'
> mv .\telegraf-1.5.2_windows_amd64\telegraf\*.* 'C:\Program Files\Telegraf'
> cd 'C:\Program Files\Telegraf'

   

  1. Create a new configuration file which includes the Graphite output-filter.
> ./telegraf.exe --output-filter graphite config > telegraf.conf

   

  1. Open the telegraf.conf file using your preferred text editor. Find the section titled[[outputs.graphite]]and change the servers and prefix options:
> servers = ["carbon.hostedgraphite.com:2003"]
> prefix = "YOUR-API-KEY.telegraf"

         

The graphite output section of the telegraf configuration file

The graphite output section of the telegraf configuration file

  1. Install telegraf to your services, and start it up:
> ./telegraf.exe -service install -config 'C:\Program Files\telegraf\telegraf.conf'
> net start telegraf

     6. Metrics will now appear in your Hosted Graphite account under the ‘telegraf’ prefix.