question

kokuljose avatar image
0 Votes"
kokuljose asked SatishBoddu-MSFT answered

Using creation time for graphs in IOT Central Dashboard

I have passes creation time from device to hub by adding the property as follows:

  msg.properties.add('iothub-creation-time-utc', current.toISOString());


And I can see the values in the Raw Values table at IOT Central. But the dashboard/views uses timestamp (time when the IOT Central get the values) which is not relevant in our usecase since there may be offline scenarios.

azure-iot-central
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @kokuljose Have you tried something like the below? for example using Node.js, below function...

 function sendTelemetry(data, schema) {
   if (deviceOnline) {
     var d = new Date();
     var payload = JSON.stringify(data);
     var message = new Message(payload);
     message.properties.add('iothub-creation-time-utc', d.toISOString());
     message.properties.add('iothub-message-schema', schema);
    
     console.log('Sending device message data:\n' + payload);
     client.sendEvent(message, printErrorFor('send event'));
   } else {
     console.log('Offline, not sending telemetry');
   }
 }
0 Votes 0 ·

I had done exactly the same. The creation-time value is show in Raw Table at IOT Central. But my question is While drawing graphs in X axis it takes the 'timestamp' value(timw when data is updated to IOT Central). Instead of that I need the creation time on X axis. My creation time and timestap will have large variations since devices operate on offline scenarios.

0 Votes 0 ·


In the attached screenshot you could see dotted lines where the device was offline. We coould see the data durig off line time in the raw table but cant see it in graphs on dashboard.

92398-screenshot-2021-04-29-105857.png


0 Votes 0 ·

So basically you are looking for customizing the graph (X-axis or Y-Axis) with your telemetry values, am I right?

what SDK are you using, may I know?

0 Votes 0 ·

1 Answer

SatishBoddu-MSFT avatar image
1 Vote"
SatishBoddu-MSFT answered

Hello @kokuljose, Below is the response from our team, I hope this helps with your initial query.

If we are setting the header iothub-creation-time-utc header on the message payload (important for the timestamp to be in UTC with NO timezone information, any timezone information will be dropped) then the telemetry tiles will show the data rendered according to the iothub-creation-time-utc


The naming of this header is not consistent across SDK's, so depending on which SDK we are using, will get a different answer.
On the dotnet sdk its called CreationTimeUTC IIRC.

If you are not seeing this behavior, please file a support ticket with Microsoft so we can debug it further.

*One more thing worth verifying is to please check the creation time actually being sent by the devices.


Instructions on how to do this can be found here: Troubleshoot device connections to Azure IoT Central | Microsoft Docs

Likely to pass the params talked about in the docs here, and additionally the --props all flags


**We should see something like this in the output, the highlighted line below is what is important:



  {    "event": {
         "origin": "fastsim-iiot-scale-test-ab-1-fastmodel-58",
         "module": "",
         "interface": "",
         "component": "",
         "properties": {
             "system": {
                 "correlation_id": "de2353ac-3e75-df36-f366-f76e326d3053",
                 "message_id": "c26d9fb0-3a69-2609-ac37-8152c7a438e8"
             },
             "application": {
                 "iothub-connection-device-id": "fastsim-iiot-scale-test-ab-1-fastmodel-58",
                //--->"iothub-creation-time-utc": "2021-05-03T20:36:18",<----//
                 "iothub-interface-id": "",
                 "iotc-hub-name": "iotc-01cc5318-4ec9-4c46-92df-a1862d8b032f",
                 "iotc-app-id": "95524991-7449-4bdd-86cf-357f789437cc"
             }
         },
         "annotations": {
             "iothub-connection-device-id": "fastsim-iiot-scale-test-ab-1-fastmodel-58",
             "iothub-connection-auth-method": "{\"scope\":\"device\",\"type\":\"sas\",\"issuer\":\"iothub\",\"acceptingIpFilterRule\":null}",
             "iothub-connection-auth-generation-id": "637520526664613270",
             "iothub-enqueuedtime": 1620074178457,
             "iothub-message-source": "Telemetry",
             "x-opt-sequence-number": 427722454,
             "x-opt-offset": "292568884579272",
             "x-opt-enqueued-time": 1620074178566
         },


Please comment in the below section to get further help in this matter.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.