你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
将时序见解 Gen1 迁移到 Azure 数据资源管理器
注意
2025 年 3 月之后,将不再支持时序见解 (TSI) 服务。 请考虑尽快将现有 TSI 环境迁移到备用解决方案。 有关弃用和迁移的详细信息,请访问我们的文档。
概述
建议从事件中心或 IoT 中心中使用新的使用者组来设置 Azure 数据资源管理器群集并等待保留期过去,然后使用时序见解环境中的相同数据填充 Azure 数据资源管理器。 如果需要从时序见解环境中导出遥测数据,建议使用时序见解查询 API 分批下载事件,并以所需的格式进行序列化。 对于参考数据,可以使用时序见解资源管理器或参考数据 API 下载参考数据集,并将其作为另一个表上传到 Azure 数据资源管理器。 然后,可以使用 Azure 数据资源管理器中的具体化视图来联接参考数据和遥测数据。 将具体化视图与 arg_max() 聚合函数结合使用,该函数将获取每个实体的最新记录,如以下示例中所示。 有关具体化视图的详细信息,请阅读以下文档:具体化视图用例。
.create materialized-view MVName on table T
{
T
| summarize arg_max(Column1,*) by Column2
}
将时序见解查询转换为 KQL
对于查询,建议在 Azure 数据资源管理器中使用 KQL。
事件
{
"searchSpan": {
"from": "2021-11-29T22:09:32.551Z",
"to": "2021-12-06T22:09:32.551Z"
},
"predicate": {
"predicateString": "([device_id] = 'device_0') AND ([has_error] != null OR [error_code] != null)"
},
"top": {
"sort": [
{
"input": {
"builtInProperty": "$ts"
},
"order": "Desc"
}
],
"count": 100
}
}
events
| 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)))
| top 100 by _timestamp desc
聚合
{
"searchSpan": {
"from": "2021-12-04T22:30:00Z",
"to": "2021-12-06T22:30:00Z"
},
"predicate": {
"eq": {
"left": {
"property": "DeviceId",
"type": "string"
},
"right": "device_0"
}
},
"aggregates": [
{
"dimension": {
"uniqueValues": {
"input": {
"property": "DeviceId",
"type": "String"
},
"take": 1
}
},
"aggregate": {
"dimension": {
"dateHistogram": {
"input": {
"builtInProperty": "$ts"
},
"breaks": {
"size": "2d"
}
}
},
"measures": [
{
"count": {}
},
{
"sum": {
"input": {
"property": "DataValue",
"type": "Double"
}
}
},
{
"min": {
"input": {
"property": "DataValue",
"type": "Double"
}
}
},
{
"max": {
"input": {
"property": "DataValue",
"type": "Double"
}
}
}
]
}
}
]
}
let _q = events | where _timestamp >= datetime("2021-12-04T22:30:00Z") and _timestamp < datetime("2021-12-06T22:30:00Z") and deviceid == "device_0";
let _dimValues0 = _q | project deviceId | sample-distinct 1 of deviceId;
_q
| where deviceid in (_dimValues0) or isnull(deviceid)
| summarize
_meas0 = count(),
_meas1 = iff(isnotnull(any(datavalue)), sum(datavalue), any(datavalue)),
_meas2 = min(datavalue),
_meas3 = max(datavalue),
by _dim0 = deviceid, _dim1 = bin(_timestamp, 2d)
| project
_dim0,
_dim1,
_meas0,
_meas1,
_meas2,
_meas3,
| sort by _dim0 nulls last, _dim1 nulls last