Telegraf : How to add a "input plugin"?
Asked Answered
W

2

21

I am a beginner with Telegraf, and I would like to install an "input plugin". I have the configuration and the .go file but I do not know what to do with it, even after searching on Google.

Thank you in advance !

Wifeless answered 6/12, 2016 at 19:23 Comment(2)
Can you explain a bit more what your issue is? Which input plugin are you trying to use?Counteract
This is an ancient post but I had to do a double take myself. The simple explanation is that the go plugin file name is the same as the inputs in the telegraf.conf . In the basic sense telegraf conf "[[inputs.pluginFilename]]". Then to see that it works assuming you just lumped everything together in a directory using version 1.* you can test with telegraf --config telegraf.conf -test. Should see the output the plugin provides.Seedy
T
11

Telegraf stuff is installed at /etc/telegraf folder and the default configuration file is /etc/telegraf/telegraf.conf.

Inside this file, you can define the input and output plugins. See Telegraf doc for more or inside the file (which is created for you for free when you install Telegraf).

There's another folder: /etc/telegraf/telegraf.d

If you put any custom configuration files there, Telegraf will pick it and it'll help you in structuring the conf files better.

So, in my case, I have the default /etc/telegraf/telegraf.conf file and I have also created two other conf files inside /etc/telegraf/telegraf.d folder.

/etc/telegraf/telegraf.d folder/myCompany-preferred-output-plugin.conf
/etc/telegraf/telegraf.d folder/myCustom-host-specific-inputs-procstat-plugin.conf
/etc/telegraf/telegraf.d folder/myCustom-inputs-exec-plugin.conf

To enable a plugin for example [[inputs.procstat]] in my case:

I have the following lines in it:

[[inputs.procstat]]
  exe = "jenkins"
  prefix = "pgrep_serviceprocess"

[[inputs.procstat]]
  exe = "telegraf"
  prefix = "pgrep_serviceprocess"

[[inputs.procstat]]
  exe = "sshd"
  prefix = "pgrep_serviceprocess"

[[inputs.procstat]]
  exe = "dockerd"
  prefix = "pgrep_serviceprocess"

## etc etc

Similarly for [[inputs.exec]] plugin, I have the other file. For ex: You can refer this link for [[inputs.exec]] example.

After that, just do:

$ sudo service telegraf restart; sleep 2
$ sudo service telegraf status
$ tail -f /var/log/telegraf/telegraf.log 

Also refer this post: How to add a plugin to Telegraf?

Threemaster answered 7/1, 2017 at 7:7 Comment(1)
Not really sure this answers the question - and this is one that I see asked all the time, and nobody seems to ever actually answer it - There are lots of telegraf plugins out there, and all of them tell you how to configure them, but none of the answers seem to really explain how to actually install them in the first place, and where those go files need to live.Bornite
K
3

You can get more information about creating plugins for Telegraf over here:

https://github.com/influxdata/telegraf/blob/master/CONTRIBUTING.md

Currently you will have to get the telegraf code from the git and re-compile it with your plugin to make your plugin work. After writing your plugin code, make sure you include it to the telegraf/plugin/inputs/all/all.go file and then make the new telegraf binary file.

Kitkitchen answered 22/11, 2017 at 1:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.