Telegraf: How to add an "input plugin"?

I start with Telegraf, and I would like to install an “input plugin”. I have a configuration and a .go file, but I don’t know what to do with it, even after searching on Google.

Thank you in advance!

+5
source share
2 answers

Telegraf is installed in the / etc / telegraf folder, and the default configuration file is /etc/telegraf/telegraf.conf .

Inside this file you can define input and output plugins. See the Telegraf Document for more or inside the file (which is created for you free of charge by installing Telegraf).

There is another folder: /etc/telegraf/telegraf.d

If you place any custom configuration files there, Telegraf will select it and this will help you better structure your conf files.

So, in my case, I have the default /etc/telegraf/telegraf.conf file, and I also created two other conf files inside the /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 the plugin, for example [[inputs.procstat]] , in my case:

I have the following lines:

 [[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 the plugin [[inputs.exec]] I have another file. For example: you can link to this link for an example [[inputs.exec]].

After that, just do:

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

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

+1
source

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

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

Currently, you will need to get the telegraf code from git and recompile it with your plugin for your plugin to work. After writing the plugin code, be sure to include it in the telegraf/plugin/inputs/all/all.go , and then create a new telegraf binary.

0
source

Source: https://habr.com/ru/post/1260896/


All Articles