Please help - how to obtain current time in the configuration file


I am new to Influxdb and Telegraf, please help me with this question:

In the Telegraf configuration file, I am making a http request with stated start and end time, as below. This is a requirement from the data source so I could not get around it. Is there any way to generate current time in the format “YYYY-MM-DDTHH:MM:SS-HH:MM” in the Telegraf configuration file then?

“startDate”: “2023-06-20T13:11:00.000Z”,
“endDate”: “2023-06-20T13:11:01.000Z”,

Many thanks,


There really isn’t at the input level. This would be a good cause to use the exec plugin to generate and make your http request and then pass the data to influxdb.

Or, depending on the popularity of the service you are querying, to submit this as a PR for a new plugin. @Jamie_NG which service you are trying to query?

Hi @srebhan thank you for the reply. I am querying an IoT database which collects data from sensors continually. I am trying to download some of the data from it and storing them at local machine using InfluxDB and Telegraph. I need to download any new data collected by this IoT database, ideally in near real-time. So I would need to use the current time to query to this database.

As I said, you need an own plugin for this as the HTTP input plugin is not stateful and will not allow dynamic queries. If you think the “IoT database” is popular, we can make that an internal Telegraf plugin. Otherwise you still do have the option to either write an external plugin or use inputs.exec to run a python script (or similar) for gathering the data.

Hi @srebhan @jpowers thanks a lot for the help. Have a nice day ahead.