Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telegraf : How to add a "input plugin"?

Tags:

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 !

like image 319
Alan Courciere Avatar asked Dec 06 '16 19:12

Alan Courciere


People also ask

Where to put Telegraf plugins?

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).

How Telegraf plugin works?

Telegraf input plugins are used with the InfluxData time series platform to collect metrics from the system, services, or third party APIs. All metrics are gathered from the inputs you enable and configure in the configuration file.

What is a plugin in Telegraf?

Telegraf is a plugin-driven agent that collects, processes, aggregates, and writes metrics. It supports four categories of plugins including input, output, aggregator, processor, and external.


1 Answers

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?

like image 187
AKS Avatar answered Oct 03 '22 07:10

AKS