How to use myself time and system time

I hope using my timestamp in my data for metics’ time . At the same time, using the system time when the data was received ,the system time will be a tag or a field .
I parse my json message by “json_v2”
please help me how to set the telegraf.conf or which plugins should I use?

Hello @liuyang0716,
It depends on your json. Can you please share it?
By default the file plugin (with the json format) will write the system time when data was recieved as the timestamp if NOTHING is specified for:

  json_time_key = ""

If you have another timestamp in the json data from when the metric was collected, then you can include it as another tag in the following option:

 tag_keys = [

Thanks for your reply.this is my json :{“fId”:125,“time”:1632968483,“items”:[{“n”:“T_125_0”,“v”:8.915515060884404}]}

I have setted the json_time_key like this :

measurement_name = “test_warning”
timestamp_path = “time”
timestamp_format = “unix”
timestamp_timezone = “Asia/Shanghai”
disable_prepend_keys = true
path = “@this
included_keys = [
tags = [“fId”, “items_n”]

and I also need create a new field to record the system time .over the documentation , I found processors.starlark , like this:

order = 1
source = ‘’’
def apply(metric):
metric.fields[“createtime”] =
return metric

Is that right?

1 Like

Hello @liuyang0716,
I always suggest using the --test flag to print your converted line protocol to stdout so you can debug anything you need from your telegraf plugin.
I also recommend setting degub=true in the agent portion of your config to get detail logs.

I believe you need to supply a timestamp in unix format with nanosecond precision like:


But I could be wrong I can’t remember exactly. However there are other options for the timestamp, see the comments in the json file input plugin:

Time format is the time layout that should be used to interpret the json_time_key.
The time must be unix, unix_ms, unix_us, unix_ns, or a time in the
“reference time”.