Telegraf Custom Plugins


#1

Hi,

I want to create a custom plugin for Telegraf but couldn’t understand how to integrate it with my existing version of Telegraf that is already running (installed from Binary). For custom plugins, do I need to build Telegraf from source code after placing the Plugin files ?

I am new to Telegraf and Influx DB, would really appreciate some pointers here.
Thanks
Akanksha


#2

The easiest way is to just use the inputs.exec input. Telegraf has the ability to run any scripts or binaries you want. There are a couple different output formats that telegraf accepts. I have a simple script that just returns the count of specific processes running on each server. It outputs the data in the influx format:

In /etc/telegraf/telegraf.d/myownmonitor.conf

[[inputs.exec]]
  commands = [ "/opt/telegraf/scripts/procmon.sh crond rsyslogd sshd snmpd winbindd" ]
  timeout = "5s"
  data_format = "influx"

Output looks like so:
$ /opt/telegraf/scripts/procmon.sh crond rsyslogd sshd snmpd winbindd

procmon,process=crond count=1
procmon,process=rsyslogd count=1
procmon,process=sshd count=3
procmon,process=snmpd count=1
procmon,process=winbindd count=3

Then I have a kapacitor script that alerts if count=0.


#3

If you want to write a custom plugin, you will need to build Telegraf from source after writing your code. You can find more information about how to do that in this blog post.


#4

Thanks a lot for the response! I tried this one and it worked. Thanks once again!