Search code examples
azure-iot-sdkazure-iot-central

How to use a custom timestamp property in IoT Central charts X axis


On an IoT Central app, is there a way to use a custom timestamp property on the X axis of the charts displayed on the dashboards?

Here's a picture of some sample raw data: Raw Data

{
 "_eventcreationtime": "2022-09-05T18:05:18.316Z",
 "Controller": {
     "Temperature4K_1": 71.468,
     "Temperature4K_2": 61.428,
     "Temperature40K_1": 39.135,
     "Temperature40K_2": 32.69,
     "TelemetryMagnetID": "Ex accusamus non commodi id ab excepturi facere et.",
     "Timestamp": "2023-01-07T19:50:11.189Z" **<- I want to use this Timestamp as the X Axis**
 },
 "_eventtype": "Telemetry",
 "_timestamp": "2022-09-05T18:05:18.369Z" **<- Looks like the the charts always use this timestamp on X Axis**
}

I would like to use the Controller.Timestamp as the value to be used on the X axis of the charts, but it looks like the _timestamp is always used.

If this is the case is there a way to set the Controller.Timestamp property has another system property before the message is sent by the device (using the C# IoT Device SDK) so that I can use the value of the source Timestamp on the X axis of the charts?


Solution

  • Posting an answer just in case others need this information.

    After reaching out to Microsoft support, I got the following answer:

    You can use the "iothub-creation-time-utc" property in message properties to set the source timestamp. If this property is set, IoTCentral will use the timestamp value of this field for dashboards/charts. If the property is not set, IoTCentral will use the enqueued time.

    So adding the code below addressed my question:

    message.properties.add('iothub-creation-time-utc', timestamp);
    

    There's also a related question here: Provide timestamp in message to IoT central