Skip to content

Commit 80682af

Browse files
authored
Merge pull request #188215 from tedvilutis/master
How to migrate TSI
2 parents 5d684f7 + ce0beef commit 80682af

26 files changed

+784
-0
lines changed

articles/time-series-insights/TOC.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
href: time-series-insights-parameterized-urls.md
8484
- name: How-to guides
8585
items:
86+
- name: Migrate to Azure Data Explorer
87+
href: migration-to-adx.md
8688
- name: Grant data access
8789
href: concepts-access-policies.md
8890
- name: Connect to Event Hubs
@@ -125,6 +127,8 @@
125127
items:
126128
- name: How to migrate to new API versions
127129
href: how-to-api-migration.md
130+
- name: How to migrate to Azure Data Explorer
131+
href: how-to-tsi-gen2-migration.md
128132
- name: Azure Time Series Insights Gen1
129133
items:
130134
- name: Explore Time Series Insights
@@ -145,6 +149,8 @@
145149
href: time-series-insights-environment-mitigate-latency.md
146150
- name: Diagnose and troubleshoot
147151
href: time-series-insights-diagnose-and-solve-problems.md
152+
- name: How to migrate to Azure Data Explorer
153+
href: how-to-tsi-gen1-migration.md
148154
- name: Reference
149155
items:
150156
- name: Time Series Insights
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
---
2+
title: 'Time Series Insights Gen1 migration to Azure Data Explorer | Microsoft Docs'
3+
description: How to migrate Azure Time Series Insights Gen 1 environments to Azure Data Explorer.
4+
ms.service: time-series-insights
5+
services: time-series-insights
6+
author: tedvilutis
7+
ms.author: tvilutis
8+
manager:
9+
ms.workload: big-data
10+
ms.topic: conceptual
11+
ms.date: 3/15/2022
12+
ms.custom: tvilutis
13+
---
14+
15+
# Migrating Time Series Insights Gen1 to Azure Data Explorer
16+
17+
## Overview
18+
19+
The recommendation is to set up Azure Data Explorer cluster with a new consumer group from the Event Hub or IoT Hub and wait for retention period to pass and fill Azure Data Explorer with the same data as Time Series Insights environment.
20+
If telemetry data is required to be exported from Time Series Insights environment, the suggestion is to use Time Series Insights Query API to download the events in batches and serialize in required format.
21+
For reference data, Time Series Insights Explorer or Reference Data API can be used to download reference data set and upload it into Azure Data Explorer as another table. Then, materialized views in Azure Data Explorer can be used to join reference data with telemetry data. Use materialized view with arg_max() aggregation function which will get the latest record per entity, as demonstrated in the following example. For more information about materialized views, read the following documentation: [Materialized views use cases] (./data-explorer/kusto/management/materialized-views/materialized-view-overview.md#materialized-views-use-cases).
22+
23+
```
24+
.create materialized-view MVName on table T
25+
{
26+
T
27+
| summarize arg_max(Column1,*) by Column2
28+
}
29+
```
30+
## Translate Time Series Insights Queries to KQL
31+
32+
For queries, the recommendation is to use KQL in Azure Data Explorer.
33+
34+
#### Events
35+
```TSQ
36+
{
37+
"searchSpan": {
38+
"from": "2021-11-29T22:09:32.551Z",
39+
"to": "2021-12-06T22:09:32.551Z"
40+
},
41+
"predicate": {
42+
"predicateString": "([device_id] = 'device_0') AND ([has_error] != null OR [error_code] != null)"
43+
},
44+
"top": {
45+
"sort": [
46+
{
47+
"input": {
48+
"builtInProperty": "$ts"
49+
},
50+
"order": "Desc"
51+
}
52+
],
53+
"count": 100
54+
}
55+
}
56+
```
57+
```KQL
58+
events
59+
| where _timestamp >= datetime("2021-11-29T22:09:32.551Z") and _timestamp < datetime("2021-12-06T22:09:32.551Z") and deviceid == "device_0" and (not(isnull(haserror)) or not(isempty(errorcode)))
60+
| top 100 by _timestamp desc
61+
62+
```
63+
64+
#### Aggregates
65+
66+
```TSQ
67+
{
68+
"searchSpan": {
69+
"from": "2021-12-04T22:30:00Z",
70+
"to": "2021-12-06T22:30:00Z"
71+
},
72+
"predicate": {
73+
"eq": {
74+
"left": {
75+
"property": "DeviceId",
76+
"type": "string"
77+
},
78+
"right": "device_0"
79+
}
80+
},
81+
"aggregates": [
82+
{
83+
"dimension": {
84+
"uniqueValues": {
85+
"input": {
86+
"property": "DeviceId",
87+
"type": "String"
88+
},
89+
"take": 1
90+
}
91+
},
92+
"aggregate": {
93+
"dimension": {
94+
"dateHistogram": {
95+
"input": {
96+
"builtInProperty": "$ts"
97+
},
98+
"breaks": {
99+
"size": "2d"
100+
}
101+
}
102+
},
103+
"measures": [
104+
{
105+
"count": {}
106+
},
107+
{
108+
"sum": {
109+
"input": {
110+
"property": "DataValue",
111+
"type": "Double"
112+
}
113+
}
114+
},
115+
{
116+
"min": {
117+
"input": {
118+
"property": "DataValue",
119+
"type": "Double"
120+
}
121+
}
122+
},
123+
{
124+
"max": {
125+
"input": {
126+
"property": "DataValue",
127+
"type": "Double"
128+
}
129+
}
130+
}
131+
]
132+
}
133+
}
134+
]
135+
}
136+
137+
```
138+
```KQL
139+
let _q = events | where _timestamp >= datetime("2021-12-04T22:30:00Z") and _timestamp < datetime("2021-12-06T22:30:00Z") and deviceid == "device_0";
140+
let _dimValues0 = _q | project deviceId | sample-distinct 1 of deviceId;
141+
_q
142+
| where deviceid in (_dimValues0) or isnull(deviceid)
143+
| summarize
144+
_meas0 = count(),
145+
_meas1 = iff(isnotnull(any(datavalue)), sum(datavalue), any(datavalue)),
146+
_meas2 = min(datavalue),
147+
_meas3 = max(datavalue),
148+
by _dim0 = deviceid, _dim1 = bin(_timestamp, 2d)
149+
| project
150+
_dim0,
151+
_dim1,
152+
_meas0,
153+
_meas1,
154+
_meas2,
155+
_meas3,
156+
| sort by _dim0 nulls last, _dim1 nulls last
157+
```
158+

0 commit comments

Comments
 (0)