Inserting timestamps into influxdb using the telegraf Azure Eventhub input plugin?

Hi All,

I’m using the telegraf input plugin[[inputs.eventhub_consumer]] to insert data into influxdb except for the timestamp field, which I can insert. Could you kindly tell me how to insert the timestamp field into influxdb2.6.1?
settings in the config file
[[inputs.eventhub_consumer]]
tag_keys = [“plant”]
json_time_key = “timestamp”
json_time_format =“yyyy-MM-ddThh:mm:ss.fffZ”
data_format = “json”
please see the event hub monitor output
[EventHubMonitor] [3:26:00 PM] Message received:
{
“plant”: “Demo”,
“Temperature”: 82,
“pressure”: 26,
“timestamp”: “2023-03-22T09:56:00.301Z”
}

Hello @RAJEESH_K,
Welcome!
Wait sorry I’m confused you can insert it? It looks like you are writing timestamps.
I like to use the --test flag to see the output of my telegraf config and the line protocol to check whether I’m generating the line protocol I expect to see.
However the timestamp format must be one of the following:

  • timestamp_path (OPTIONAL): You can define a query with GJSON Path Syntax to set a timestamp from the JSON input. The query must return a single data value or it will default to the current time.
  • timestamp_format (OPTIONAL, but REQUIRED when timestamp_query is defined: Must be set to unix, unix_ms, unix_us, unix_ns, or the Go “reference time” which is defined to be the specific time: Mon Jan 2 15:04:05 MST 2006
  • timestamp_timezone (OPTIONAL, but REQUIRES timestamp_query: This option should be set to a Unix TZ value, such as America/New_York, to Local to utilize the system timezone, or to UTC. Defaults to UTC

Or JSON input data format | Telegraf Documentation

## Time key is the key containing the time that should be used to create the
  ## metric.
  json_time_key = ""

  ## Time format is the time layout that should be used to interprete the
  ## json_time_key.  The time must be `unix`, `unix_ms` or a time in the
  ## "reference time".
  ##   ex: json_time_format = "Mon Jan 2 15:04:05 -0700 MST 2006"
  ##       json_time_format = "2006-01-02T15:04:05Z07:00"
  ##       json_time_format = "unix"
  ##       json_time_format = "unix_ms"
  json_time_format = ""

So I would try putting my json_time_format = "2023-03-22T09:56:00.301Z"
Let me know if that works.

Hi Anaisdg,

Thank you for responding.

No, I’m unable to inserting the time.

If json_time_key and json_time_format providing json object is not inserting into db.


Please look at the different json_time_formts that are used.
Please note that I changed the input time code to match the appropriate time format.
data_format = “json”

data_format = “json_v2”

json_name_key = “Name”
tag_keys = [“plant”]

json_string_fields = [ “timestamp” ]

json_time_key = “timestamp”

json_time_format = “2006-01-02 15:04:05.000-0700”

json_time_format = “2006-01-02T15:04:05.000000Z”

json_time_format = “yyyy-MM-dd’T’HH:mm:ss.SSS’Z’”

json_time_format =“2010-04-17T17:00:00.000Z”

json_time_format = “2023-03-22T09:56:00.301Z”

json_time_format = “2019-03-06T11:19:48.0000855Z”

json_time_format =“yyyy-MM-ddThh:mm:ss.fffZ”

json_time_format =“2019-10-31 12:13:14”

json_time_format = “unix”

json_time_format =“2006-01-02T15:04:05Z00:00”

json_time_format = “02 Jan 06 15:04 MST”

[[inputs.eventhub_consumer.json_v2]]

measurement_name = “ICPro” # A string that will become the new measurement name

# measurement_name_path = “” # A string with valid GJSON path syntax, will override measurement_name

timestamp_path = “timestamp” # A string with valid GJSON path syntax to a valid timestamp (single value)

timestamp_format = “2023-03-22T09:56:00.301Z” # A st