Skip to content

Commit 2297e88

Browse files
authored
Merge pull request #182050 from dominicbetts/central-add-data-mapping
Add IoT Central data mapping
2 parents dfa1025 + 090c08d commit 2297e88

12 files changed

+94
-6
lines changed

articles/iot-central/.openpublishing.redirection.iot-central.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,11 +1309,6 @@
13091309
"source_path_from_root": "/articles/iot-central/core/howto-show-hide-chat.md",
13101310
"redirect_url": "/azure/iot-central",
13111311
"redirect_document_id": false
1312-
},
1313-
{
1314-
"source_path_from_root": "/articles/iot-central/core/howto-map-data.md",
1315-
"redirect_url": "/azure/iot-central",
1316-
"redirect_document_id": false
13171312
}
13181313
]
13191314
}

articles/iot-central/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@
147147
href: core/howto-export-data.md
148148
- name: Export data to cloud destinations (legacy)
149149
href: core/howto-export-data-legacy.md
150+
- name: Transform data internally on ingress
151+
href: core/howto-map-data.md
150152
- name: Transform data internally for export
151153
href: core/howto-transform-data-internally.md
152154
- name: Transform data externally
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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).

articles/iot-central/core/howto-transform-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ IoT devices send data in various formats. To use the device data with your IoT C
2323
This article shows you how to transform device data outside of IoT Central either at ingress or egress.
2424

2525
> [!NOTE]
26-
> IoT Central can also transform data internally, to learn more see [Transform data inside your IoT Central application for export](howto-transform-data-internally.md).
26+
> IoT Central can also transform data internally, to learn more see [Map telemetry on ingress to IoT Central](howto-map-data.md) and [Transform data inside your IoT Central application for export](howto-transform-data-internally.md).
2727
2828
The following diagram shows three routes for data that include transformations:
2929

59.2 KB
Loading
37.8 KB
Loading
53.7 KB
Loading
36.4 KB
Loading
37.4 KB
Loading
62.3 KB
Loading

0 commit comments

Comments
 (0)