How to schedule a Telegraf inputs.exec

I’m collecting data that updates only once a day at 12 AM. Instead of polling for new data using a short interval I would like to schedule the inputs.exec execution using a cron-like schedule such as 1 12 * * * . Is there a workaround for this?

The plugin does not have to be executed with the global interval of the agent.
You can set an individual interval for each plugin.

[[inputs.exec]]
  interval = "24h"

Other possibilities that came to my mind spontaneously would be:

  1. Query the current time in your custom exec plugin with time.now() (in your programming language) and return a metric to telegraf only once a day.

  2. Execute a separate script with a cron job once a day and send the result e.g. to the telegraf plugin inputs.socket_listener or inputs.tail


Unfortunately, as far as I know, Telegraf does not yet offer the possibility to define an interval with the cron syntax.
But maybe that will come in the future?
Would it be worth a feature request?

Edit: Yes :wink:

1 Like