Test if plugin is working

What is the best way to test if a specific enabled plugin is working.

To test an output plugin you’ll want to capture the output, so you can see whether it looks the way you expected. Most of the output plugins provided for Telegraf send data over the network, so you could use a tool like netcat, ngrep, or tcpdump to capture that data. If you’re using the file output plugin, you can just check the data on disk.

If you want to test a plugin that collects or processes data, one way to do this is to set up a new UDP output plugin that runs in parallel with the existing output plugins. Then you can use a tool like netcat to capture the output and verify it. You can find a more detailed example on how to do this in the “Troubleshooting” section of the Telegraf documentation.

If you’re writing automated tests, the same principles apply: give Telegraf an input, capture the output and make sure it looks the way you expect.

1 Like

I was leaning to the UDP way of capturing data. Thanks for confirming that.

If all you want to do is a test whether an input plugin is able to collect data, there is a simple way to do that: use Telegraf’s --test argument, which will gather metrics once, print them to stdout, and exit.