You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/time-series-insights/time-series-insights-update-how-to-shape-events.md
+62-24Lines changed: 62 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,40 +8,56 @@ ms.workload: big-data
8
8
ms.service: time-series-insights
9
9
services: time-series-insights
10
10
ms.topic: conceptual
11
-
ms.date: 02/14/2020
11
+
ms.date: 02/24/2020
12
12
ms.custom: seodec18
13
13
---
14
14
15
15
# Shape events with Azure Time Series Insights Preview
16
16
17
-
This article helps you shape your JSON file for ingestion and to maximize the efficiency of your Azure Time Series Insights Preview queries.
17
+
This article defines best practices to shape your JSON payloads for ingestion in Azure Time Series Insights and to maximize the efficiency of your Preview queries.
18
18
19
19
## Best practices
20
20
21
-
Think about how you send events to Time Series Insights Preview. Namely, you should always:
21
+
It's best to carefully consider how you send events to your Time Series Insights Preview environment.
22
+
23
+
General best practices include:
22
24
23
25
* Send data over the network as efficiently as possible.
24
26
* Store your data in a way that helps you aggregate it more suitably for your scenario.
25
27
26
-
For the best query performance, do the following:
28
+
For the best query performance, adhere to the following rules of thumb:
27
29
28
-
* Don't send unnecessary properties. Time Series Insights Preview bills you on your usage. It's best to store and process the data that you'll query.
29
-
* Use instance fields for static data. This practice helps you avoid sending static data over the network. Instance fields, a component of the Time Series Model, work like reference data in the Time Series Insights service that's generally available. To learn more about instance fields, read [Time Series Model](./time-series-insights-update-tsm.md).
30
+
* Don't send unnecessary properties. Time Series Insights Preview bills by usage. It's best to store and process only the data that you'll query.
31
+
* Use instance fields for static data. This practice helps to avoid sending static data over the network. Instance fields, a component of the Time Series Model, work like reference data in the Time Series Insights service that's generally available. To learn more about instance fields, read [Time Series Model](./time-series-insights-update-tsm.md).
30
32
* Share dimension properties among two or more events. This practice helps you send data over the network more efficiently.
31
33
* Don't use deep array nesting. Time Series Insights Preview supports up to two levels of nested arrays that contain objects. Time Series Insights Preview flattens arrays in messages into multiple events with property value pairs.
32
34
* If only a few measures exist for all or most events, it's better to send these measures as separate properties within the same object. Sending them separately reduces the number of events and might improve query performance because fewer events need to be processed.
33
35
34
-
During ingestion, payloads that contain nesting will be flattened, such that the column name is a single value with a delineator. Time Series Insights Preview uses underscores for delineation. Note that this is a change from the GA version of the product which used periods. During preview, there is a caveat around flattening, which is illustrated in the second example below.
36
+
## Column flattening
37
+
38
+
During ingestion, payloads that contain nested objects will be flattened so that the column name is a single value with a delineator.
39
+
40
+
* For example, the following nested JSON:
41
+
42
+
```JSON
43
+
"data": {
44
+
"flow": 1.0172575712203979,
45
+
},
46
+
```
47
+
48
+
Becomes: `data_flow` when flattened.
35
49
36
-
## Examples
50
+
> [!IMPORTANT]
51
+
> * Azure Time Series Insights Preview uses underscores (`_`) for column delineation.
52
+
> * Note the difference from General Availability which uses periods (`.`) instead.
37
53
38
-
The following example is based on a scenario where two or more devices send measurements or signals. The measurements or signals can be *Flow Rate*, *Engine Oil Pressure*, *Temperature*, and *Humidity*.
54
+
More complex scenarios are illustrated below.
39
55
40
-
In the example, there's a single Azure IoT Hub message where the outer array contains a shared section of common dimension values. The outer array uses Time Series Instance data to increase the efficiency of the message.
56
+
#### Example 1:
41
57
42
-
The Time Series Instance contains device metadata. This metadata doesn't change with every event, but it does provide useful properties for data analysis. To save on bytes sent over the wire and make the message more efficient, consider batching common dimension values and using Time Series Instance metadata.
58
+
The following scenario has two (or more) devices that send the measurements (signals): *Flow Rate*, *Engine Oil Pressure*, *Temperature*, and *Humidity*.
43
59
44
-
### Example 1:
60
+
There's a single Azure IoT Hub message sent where the outer array contains a shared section of common dimension values (note the two device entries contained in the message).
45
61
46
62
```JSON
47
63
[
@@ -72,10 +88,23 @@ The Time Series Instance contains device metadata. This metadata doesn't change
72
88
]
73
89
```
74
90
75
-
### Time Series Instance
91
+
**Takeaways:**
92
+
93
+
* The example JSON has an outer array that uses [Time Series Instance](./time-series-insights-update-tsm.md#time-series-model-instances) data to increase the efficiency of the message. Even though Time Series Instances device metadata's not likely to change, it often provides useful properties for data analysis.
94
+
95
+
* The JSON combines two or more messages (one from each device) into a single payload saving on bandwidth over time.
96
+
97
+
* Individual series data points for each device are combined into a single **series** attribute reducing the need to continuously stream updates for each device.
98
+
99
+
> [!TIP]
100
+
> To reduce the number of messages required to send data and make telemetry more efficient, consider batching common dimension values and Time Series Instance metadata into a single JSON payload.
101
+
102
+
#### Time Series Instance
103
+
104
+
Let's take a closer look at how to use [Time Series Instance](./time-series-insights-update-tsm.md#time-series-model-instances) to shape your JSON more optimally.
76
105
77
106
> [!NOTE]
78
-
> The Time Series ID is *deviceId*.
107
+
> The [Time Series IDs](./time-series-insights-update-how-to-id.md) below are *deviceIds*.
79
108
80
109
```JSON
81
110
[
@@ -110,26 +139,28 @@ The Time Series Instance contains device metadata. This metadata doesn't change
110
139
]
111
140
```
112
141
113
-
Time Series Insights Preview joins a table (after flattening) during query time. The table includes additional columns, such as **Type**. The following example demonstrates how you can [shape](./time-series-insights-send-events.md#supported-json-shapes) your telemetry data.
142
+
Time Series Insights Preview joins a table (after flattening) during query time. The table includes additional columns, such as **Type**.
|`FYYY`| LINE_DATA COMMON | SIMULATOR | Battery System | 2018-01-17T01:18:00Z | 0.58015072345733643 | 22.2 |
120
149
121
-
In the preceding example, note the following points:
150
+
> [!NOTE]
151
+
> The preceding table represents the query view in the [Time Series Preview Explorer](./time-series-insights-update-explorer.md).
122
152
123
-
* Static properties are stored in Time Series Insights Preview to optimize data sent over the network.
153
+
**Takeaways:**
154
+
155
+
* In the preceding example, static properties are stored in Time Series Insights Preview to optimize data sent over the network.
124
156
* Time Series Insights Preview data is joined at query time through the Time Series ID that's defined in the instance.
125
157
* Two layers of nesting are used. This number is the most that Time Series Insights Preview supports. It's critical to avoid deeply nested arrays.
126
158
* Because there are few measures, they're sent as separate properties within the same object. In the example, **series_Flow Rate psi**, **series_Engine Oil Pressure psi**, and **series_Flow Rate ft3/s** are unique columns.
127
159
128
160
>[!IMPORTANT]
129
161
> Instance fields aren't stored with telemetry. They're stored with metadata in the Time Series Model.
130
-
> The preceding table represents the query view.
131
162
132
-
### Example 2:
163
+
####Example 2:
133
164
134
165
Consider the following JSON:
135
166
@@ -143,13 +174,20 @@ Consider the following JSON:
143
174
"data_flow" : 1.76435072345733643
144
175
}
145
176
```
146
-
In the example above, the flattened `data_flow` property would present a naming collision with the `data_flow` property. In this case, the *latest* property value would overwrite the earlier one. If this behavior presents a challenge for your business scenarios, please contact the TSI team.
147
177
148
-
> [!WARNING]
149
-
> In cases where duplicate properties are present in the same event payload due to flattening or
150
-
> another mechanism, the latest property value is stored, overwritting any previous values.
178
+
In the example above, the flattened `data["flow"]` property would present a naming collision with the `data_flow` property.
151
179
180
+
In this case, the *latest* property value would overwrite the earlier one.
181
+
182
+
> [!TIP]
183
+
> Contact the Time Series Insights team for more assistance!
184
+
185
+
> [!WARNING]
186
+
> * In cases where duplicate properties are present in the same (singular) event payload due to flattening or another mechanism, the latest > property value is stored, over-writing any previous values.
187
+
> * Series of combined events will not override one another.
152
188
153
189
## Next steps
154
190
155
-
To put these guidelines into practice, read [Azure Time Series Insights Preview query syntax](./time-series-insights-query-data-csharp.md). You'll learn more about the query syntax for the Time Series Insights Preview REST API for data access.
191
+
* To put these guidelines into practice, read [Azure Time Series Insights Preview query syntax](./time-series-insights-query-data-csharp.md). You'll learn more about the query syntax for the Time Series Insights [Preview REST API](https://docs.microsoft.com/rest/api/time-series-insights/preview) for data access.
192
+
193
+
* Combine JSON best practices with [How to Time Series Model](./time-series-insights-update-how-to-tsm.md).
0 commit comments