# Insert timestamp in \_time column using telegraf/eventhub

**URL:** <https://community.influxdata.com/t/insert-timestamp-in-time-column-using-telegraf-eventhub/35103>\
**Category:** Systems\
**Tags:** influxdb, telegraf\
**Created:** [July 29, 2024, 10:19pm UTC](https://community.influxdata.com/t/insert-timestamp-in-time-column-using-telegraf-eventhub/35103 "2024-07-29T22:19:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alsahmou](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/alsahmou/32/16034_2.png) [@alsahmou](https://community.influxdata.com/u/alsahmou)\
**Post date:** [July 29, 2024, 10:19pm UTC](https://community.influxdata.com/t/insert-timestamp-in-time-column-using-telegraf-eventhub/35103/1 "2024-07-29T22:19:58Z")

</div>

I am trying to change the \_time column with ‘machine\_timestamp’ that I am sending to Telegraf via Eventhub.  
Here is a sample of the message I am sending

{‘machine\_timestamp’: ‘2024-07-29T14:30:00Z’,  
‘measurement’: ‘TEST’,  
‘sig’: ‘Temp’,  
‘table\_name’: ‘High Temp’,  
‘value’: 24.93352988307621}

And here is the configuration of my Telegraf  
[agent]  
collection\_jitter = “0s”  
debug = true  
flush\_interval = “1s”  
flush\_jitter = “0s”  
hostname = “”  
interval = “1s”  
logfile = “”  
metric\_batch\_size = 1000  
metric\_buffer\_limit = 10000  
omit\_hostname = true  
precision = “”  
quiet = false  
round\_interval = true  
[[processors.enum]]  
[[processors.enum.mapping]]  
dest = “status\_code”  
field = “status”  
[processors.enum.mapping.value\_mappings]  
critical = 3  
healthy = 1  
problem = 2  
[[processors.converter]]  
[processors.converter.fields]  
float = [  
“value”,  
“min”,  
“max”,  
“mean”,  
“threesigma”  
]

```
[[outputs.influxdb_v2]]
  bucket = "IFMP"
  organization = "organization"
  token = "$TOKEN"
  urls = [
    "https://urll.com"
  ]

[[inputs.statsd]]
  allowed_pending_messages = 10000
  metric_separator = "_"
  percentile_limit = 1000
  percentiles = [
    50.0,
    95.0,
    99.0
  ]
  service_address = ":8125"
[[inputs.eventhub_consumer]]
  connection_string = "$EH_CONN_STRING"
  data_format = "json"
  json_time_key = "machine_timestamp"
  json_time_format = "RFC3339"
  json_string_fields = [
    "value",
    "min",
    "max",
    "mean",
    "threesigma"
  ]
  name_override = "Measurement_Name"
  tag_keys = [
    "sig",
    "table_name",
    "mountpoint",
    "interface"
  ]

```

When I use this config, I see from the logs that telegraf output data to influxDB  
2024-07-29T22:08:17Z D! [outputs.influxdb\_v2] Wrote batch of 300 metrics in 18.539421ms  
but I see no data in influxDB  
When I remove the json\_time\_key and json\_time\_format lines the data is written, but obviously I am not replacing the \_time column value with anything.

How can I insert my own timestamps to influxDB so that they show up under the \_time column?

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [August 1, 2024, 8:05pm UTC](https://community.influxdata.com/t/insert-timestamp-in-time-column-using-telegraf-eventhub/35103/2 "2024-08-01T20:05:23Z")

</div>

Hello @alsahmou,

```auto
[[inputs.eventhub_consumer]]
  connection_string = "$EH_CONN_STRING"
  data_format = "json"
  json_time_key = "machine_timestamp" # This should match your JSON timestamp key
  json_time_format = "2006-01-02T15:04:05Z07:00" # This is the layout for RFC3339
  json_string_fields = [
    "value",
    "min",
    "max",
    "mean",
    "threesigma"
  ]
  name_override = "Measurement_Name"
  tag_keys = [
    "sig",
    "table_name",
    "mountpoint",
    "interface"
  ]

[[outputs.influxdb_v2]]
  bucket = "IFMP"
  organization = "organization"
  token = "$TOKEN"
  urls = [
    "https://urll.com"
  ]

```

You could try making the layout format like above but the format you chose should work.

You could also try using the json\_v2 data format instead. But that should work. I don’t see anything wrong off the bat.  
@jpowers do you? Thank you!

Ps @alsahmou what are you usign telegraf and influxdb for? I like learning about what community members are getting up to:)

---

<div class="post-metadata">

**Author:** ![jpowers](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jpowers/32/8569_2.png) [@jpowers](https://community.influxdata.com/u/jpowers)\
**Post date:** [August 1, 2024, 9:36pm UTC](https://community.influxdata.com/t/insert-timestamp-in-time-column-using-telegraf-eventhub/35103/3 "2024-08-01T21:36:27Z")

</div>

Hi,

I think @alsahmou asked this in slack as well, so I’ll paste my response here:

> When someone says it doesn’t show up in influxdb, but the logs say that it was written, this is usually a UI issue with whatever your are querying influxdb with. For example, your dates is from yesterday, does your UI display more than 24 hours of data? or if you are using grafana or something else, same question.

> We ask this because when you don’t set the timestamp, then the current time is used, and if you can see that it is much more likely that recent data points are shown in the default UI time range

I think @alsahmou came back and said this was the issue, namely the UI scale was only the last 10 minutes.

Hope that helps!
