|
| 1 | +--- |
| 2 | +title: Transform telemetry on ingress to IoT Central | Microsoft Docs |
| 3 | +description: To use complex telemetry from devices, you can use mappings to transform it as it arrives in your IoT Central application. This article describes how to map device telemetry on ingress to IoT Central. |
| 4 | +author: dominicbetts |
| 5 | +ms.author: dobett |
| 6 | +ms.date: 11/22/2021 |
| 7 | +ms.topic: how-to |
| 8 | +ms.service: iot-central |
| 9 | +services: iot-central |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +# Map telemetry on ingress to IoT Central |
| 14 | + |
| 15 | +Data mapping lets you transform complex device telemetry into structured data inside IoT Central. For each of your devices, you can map a specific JSON path in the device telemetry message to an _alias_. An alias is a friendly name for the target you're mapping to. IoT Central uses the mappings to transform telemetry on the way in to IoT Central. You can use the mapped telemetry to: |
| 16 | + |
| 17 | +* Create device templates and device management experiences in IoT Central. |
| 18 | +* Normalize telemetry from different devices by mapping JSON paths on multiple devices to a common alias. |
| 19 | +* Export to destinations outside IoT Central. |
| 20 | + |
| 21 | +:::image type="content" source="media/howto-map-data/map-data-summary.png" alt-text="Diagram that summarizes the mapping process in IoT Central." border="false"::: |
| 22 | + |
| 23 | +## Map telemetry for your device |
| 24 | + |
| 25 | +A mapping uses a [JSONPath](https://www.npmjs.com/package/jsonpath) expression to identify the value in an incoming telemetry message to map to an alias. |
| 26 | + |
| 27 | +A JSONPath expression begins with the `$` character, which refers to the root element of the message. The `$` is followed by a sequence of child elements separated using square brackets. For example: |
| 28 | + |
| 29 | +```json |
| 30 | +$["messages"]["tmp"] |
| 31 | + |
| 32 | +$["opcua"]["payload"][0]["value"] |
| 33 | + |
| 34 | +$["Messages"]["Payload"]["nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1"]["Value"] |
| 35 | +``` |
| 36 | + |
| 37 | +IoT Central uses a subset of the JSONPath expression syntax: |
| 38 | + |
| 39 | +* Each segment can only be a non-negative number or a string enclosed in double quotation marks. |
| 40 | +* A segment can't contain backslash, square bracket, or double quotation marks. |
| 41 | +* A JSON path can't exceed 1,000 characters. |
| 42 | + |
| 43 | +To create a mapping in your IoT Central application, choose one of the following options to navigate to the **Map data** panel: |
| 44 | + |
| 45 | +* From any device page, select **Manage device > Map data**: |
| 46 | + |
| 47 | + :::image type="content" source="media/howto-map-data/manage-device.png" alt-text="Screenshot that shows the **Map data** menu item."::: |
| 48 | + |
| 49 | +* From the **Raw data** view for your device, expand any telemetry message, hover the mouse pointer over a path, and select **Add alias**. The **Map data** panel opens with the JSONPath expression copied to the **JSON path** field: |
| 50 | + |
| 51 | + :::image type="content" source="media/howto-map-data/raw-data.png" alt-text="Screenshot that shows the **Add alias** option on the **Raw data** view."::: |
| 52 | + |
| 53 | +The left-hand side of the **Map data** panel shows the latest message from your device. Hover to mouse pointer over any part of the data and select **Add Alias**. The JSONPath expression is copied to **JSON path**. Add an **Alias** name with no more than 64 characters. Add as many mappings as you need and then select **Save**: |
| 54 | + |
| 55 | +:::image type="content" source="media/howto-map-data/map-data.png" alt-text="Screenshot of the **Map data** view showing the Json path and alias."::: |
| 56 | + |
| 57 | +For a given device: |
| 58 | + |
| 59 | +* No two mappings can have the same JSON path. |
| 60 | +* No two mappings can have the same alias. |
| 61 | + |
| 62 | +> [!TIP] |
| 63 | +> You may need to wait for several minutes for your device to send a telemetry message to display in the left hand panel. If there's still no data in left hand panel, you can manually enter a JSONPath expression in the **JSON path** field. |
| 64 | +
|
| 65 | +To verify that IoT Central is mapping the telemetry, navigate to **Raw data** view for your device and check the `_mappeddata` section: |
| 66 | + |
| 67 | +:::image type="content" source="media/howto-map-data/mapped-data.png" alt-text="Screenshot that shows the mapped data section in a message in the **Raw data** view."::: |
| 68 | + |
| 69 | +If you don't see your mapped data after refreshing the **Raw data** several times, check that the JSONPath expression you're using matches the structure of the telemetry message. |
| 70 | + |
| 71 | +For IoT Edge devices, the data mapping applies to the telemetry from all the IoT Edge modules and hub. You can't apply mappings to a specific IoT edge module. |
| 72 | + |
| 73 | +For devices assigned to a device template, you can't map data for components or inherited interfaces. However, you can map any data from your device before you assign it to a device template. |
| 74 | + |
| 75 | +## Manage mappings |
| 76 | + |
| 77 | +To view, edit, or delete mappings, navigate to the **Mapped aliases** page. Select a mapping to edit or delete it. You can select multiple mappings and delete them at the same time: |
| 78 | + |
| 79 | +:::image type="content" source="media/howto-map-data/mapped-aliases.png" alt-text="Screenshot that shows the **Mapped aliases** view with the edit and delete buttons."::: |
| 80 | + |
| 81 | +By default, data exports from IoT Central include mapped data. To exclude mapped data, use a [data transformation](howto-transform-data-internally.md) in your data export. |
| 82 | + |
| 83 | +## Next steps |
| 84 | + |
| 85 | +Now that you've learned how to map data for your device, a suggested next step is to learn [How to use analytics to analyze device data](howto-create-analytics.md). |
0 commit comments