Telegraf MQTT to Influxdb - Add custom field for current date

I have set my telegraf config for write my Json topic was write in collection in Influxdb.
It works well.
But i want add the current date like a field for know the write date.
How can i make this in my [[inputs.mqtt_consumer]] or [[outputs.influxdb_v2]] area?

If no timestmap is generated on data when it comes in, then the timestamp is set when data is sent to InfluxDB by the output.


I have a date property “ts” in my json message. It is mapped to the “_time” field of each message.
json_time_key = “ts”

I want to add one as a given (field) which is the current date()

I want to add one as a given (field) which is the current date()

If you need to use the current date, then you would need to use the Starlark processor to add this. Similar to this example, but instead of setting metric.time set metric.fields["time"] or whatever you want to call it.

Storing the time of parsing in a field is an unusual request. Generally the user wants the time in their data set as the timestamp or they want the current time set as the timestamp, which the serializes/outputs handle.

I want both. Message time and write date for trace sequence sended.
Thanks, but i don’t have code actualy for write my messages in influx.
What is the star file, where i can define it ?
and do i have to call if from configuration file ?

Please see the starlark plugin readme. Which details how you can import a star script.