Interval-config of a telegraf plugin isn't working

Hi,
I have Telegraf 1.29.2 running in a Debian LXC on Proxmox.
The agent is running with an interval of 10 seconds.
In the telegraf.d folder I have a separate conf file containing the following config

[[inputs.execd]]
  interval = '1h'
  command = ["python3", "/home/my_python_script_that_prints_data_in_influx_line_protocol.py"]
  data_format = "influx"

I would like to run this plugin every hour, not every 10 seconds.
But it still runs every 10 seconds.

Can someone tell me what I am doing wrong?

I don’t know if it is important but:
In the telegraf.d folder I have a second conf file that also calls a python script using the ‘inputs.exed’ plugin. This one has to run every 10 seconds, so this one runs correctly.

Thank you!
Best regards
mattb

The interval setting is the correct option. However, you are using execd, which is a service input. It does not run on each gather interval but instead expects data to get sent to it. Meaning the interval option is ignored. You will find the following in the plugin readme:

This plugin is a service input. Normal plugins gather metrics determined by the interval setting. Service plugins start a service to listens and waits for metrics or events to occur. Service plugins have two key differences from normal plugins:

1. The global or plugin specific `interval` setting may not apply
2. The CLI options of `--test`, `--test-wait`, and `--once` may not produce output for this plugin

If you want to run a command on a set interval, then look to the exec plugin.

Hey, that was fast :smiley:
I now use the inputs.exec plugin and it’s working.

Here’s the working conf:

[[inputs.exec]]
  interval = "1h"
  commands = ["python3 /home/my_python_script_that_prints_data_in_influx_line_protocol.py"]
  timeout = "1m"
  data_format = "influx"

Thank you very much!

1 Like