How to use custom timestamp in Time series?

Hi!

I am using Grafana v10.2.2 (docker image) with a Data source from InfluxDB. My data has multiple of timestamps which are stored in InfluxDB as Epoch time value for each packet.

I wonder how can I use these timestamp in my data as the X-axis value in a Grafana Time Series visualization instead of the time data inserted into InfluxDB?

The default option seems to be the time data inserted into InfluxDB. And I don’t see an option to change it!

TIA & Have a great day!!

(I want to use receive_at_gw as X-axis value here)

(Default option that use the InfluxDB inserted time)

Welcome @manhthaospm to the Grafana forum.

Where do the values for
receive_at_gw
come from? Something other than InfluxDB?

Hi @grant2,

Thanks for your response!

The receive_at_gw is from the LoRaWAN Network Server called The Things Network (TTN). TTN provides data via MQTT. I subscribes to the topics of my device, monitors and inserts the data into InfluxDB. The original unit of this field is milliseconds.

My current “walk around” solution is inserting data with specified time field (the time I want to use as x-axis in Grafana) in the InfluxDB query. That’s why you see my receive_at_gw are basically multiplied by 1e6 to be adapt to InfluxDB time field unit. However, this solution requires creating multiple database (or measurements in InfluxDB) of the same data with different inserted time.

Sorry for my long explaination!

what does the query look like when you click the :pen:

Hi @manhthaospm

I’m sorry, but I am still not clear. If you record data via MQTT and insert into InfluxDB with the timestamp at which the reading was inserted, isn’t that the purpose of using a time series database? You mentioned that you instead want to use a different time value (which you insert into InfluxDB as apparently a second time field). Can I ask why this is so?

The only thing I can figure is that there is some sort of inherent lag you are trying to avoid by using another secondary time field, but maybe you can explain. Regardless, I feel you are entering a space where few people are using a custom or “alternative” time in their Influx database and thus might have difficulty getting help.

Hi @yosiasz,

Thanks, I don’t know if this is exactly what you meant. The raw querries in my pictures are:

SELECT last("sat_id") AS "SatID", last("receive_at_gw") AS "Timestamp" FROM "lpp2_with_decoded_data" WHERE ("device_id"::field = 'dkaiot2-terrestrial') AND $timeFilter GROUP BY time($__interval) fill(none)

and

SELECT last("sat_id") FROM "lpp2_with_decoded_data" WHERE ("device_id"::field = 'dkaiot3-terrestrial') AND $timeFilter GROUP BY time($__interval) fill(none)