Schema formats for IoT Hub messages

This topic explains how you should design a message schema that you can use in IoT Intelligence.

Message requirements

The following rules apply to the monitoring of messages in IoT Intelligence:

  • Message schemas must be in JavaScript Object Notation (JSON) format.

  • A UNIX timestamp property, where the value is expressed in milliseconds (ms), must be present in the Microsoft Azure IoT Hub message.

  • A message is tracked only if it contains all the properties that are defined in the scenario setup. For example, if you define id, timestamp, and value properties, the following message is monitored.

    {
        "id": "IoTInt.Machine1225.PartOut",
        "timestamp": 1576016821614,
        "value": True
    }
    

    This message isn't monitored, because the value property is missing.

    {
        "id": "IoTInt.Machine1225.PartOut",
        "timestamp": 1576016821614,
    }
    
  • IoT Intelligence ignores properties in the message that aren't defined in the scenario configuration. For example, if you define id, timestamp, and value properties, IoT Intelligence will monitor all the following messages.

    {
        "id": "IoTInt.Machine1225.PartOut",
        "timestamp": 1576016821614,
        "value": True
    },
    {
        "id": "IoTInt.Machine1225.PartOut",
        "timestamp": 1576016821614,
        "value": True,
        "machine" : "Machine1225",
    },
    {
        "id": "IoTInt.Machine1225.PartOut",
        "timestamp": 1576016821614,
        "value": True,
         "activity": "PartOut"
    },
    
  • IoT Intelligence silently ignores messages that don't match the scenario configuration criteria.

  • You can define and use multiple types of message schemas.

  • Not every type of message schema must be defined. Only schemas that will be used for the IoT Intelligence scenarios must be defined.

Id-value pair schema

An id-value pair is a common pattern for IoT Intelligence message schemas. By using an id-value pair, you ensure that your message schema is the same across all the scenarios. For example, here is a message for the Equipment downtime or Production delays scenario.

{
    "id": "IoTInt.Machine1225.PartOut",
    "timestamp": 1576016821614,
    "value": True
}

Here is a message for the Product quality scenario.

{
    "id": "IoTInt.Machine1225.Temperature",
    "timestamp": 1576016821614,
    "value": 105
}

Both the preceding messages contain id and value properties. The id values can be mapped in the Signal Data Values table during scenario setup. For the Equipment downtime scenario, you will map the IoTInt.Machine1225.PartOut value. For the Product quality scenario, you will map the IoTInt.Machine1225.Temperature value.

For more information, see Azure IoT Hub Documentation.