gpt4 book ai didi

json - 使用流分析将自定义事件维度从 Application Insights 导出到 SQL

转载 作者:行者123 更新时间:2023-12-04 16:43:15 25 4
gpt4 key购买 nike

我正在按照示例演练 Export to SQL from Application Insights using Stream Analytics 进行操作。我正在尝试导出自定义事件维度(下面的 JSON 示例中的 context.custom.dimensions),该维度作为嵌套 JSON 数组添加到数据文件中。如何展平 context.custom.dimensions 中的维度数组以导出到 SQL?

JSON...

{
"event": [
{
"name": "50_DistanceSelect",
"count": 1
}
],
"internal": {
"data": {
"id": "aad2627b-60c5-48e8-aa35-197cae30a0cf",
"documentVersion": "1.5"
}
},
"context": {
"device": {
"os": "Windows",
"osVersion": "Windows 8.1",
"type": "PC",
"browser": "Chrome",
"browserVersion": "Chrome 43.0",
"screenResolution": {
"value": "1920X1080"
},
"locale": "unknown",
"id": "browser",
"userAgent": "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36"
},
"application": {},
"location": {
"continent": "North America",
"country": "United States",
"point": {
"lat": 38.0,
"lon": -97.0
},
"clientip": "0.115.6.185",
"province": "",
"city": ""
},
"data": {
"isSynthetic": false,
"eventTime": "2015-07-15T23:43:27.595Z",
"samplingRate": 0.0
},
"operation": {
"id": "2474EE6F-5F6F-48C3-BA43-51636928075A"
},
"user": {
"anonId": "BA05C4BE-1C42-482F-9836-D79008E78A9D",
"anonAcquisitionDate": "0001-01-01T00:00:00Z",
"authAcquisitionDate": "0001-01-01T00:00:00Z",
"accountAcquisitionDate": "0001-01-01T00:00:00Z"
},
"custom": {
"dimensions": [
{
"CategoryAction": "click"
},
{
"SessionId": "73ef454d-fa39-4125-b4d0-44486933533b"
},
{
"WebsiteVersion": "3.0"
},
{
"PageSection": "FilterFind"
},
{
"Category": "EventCategory1"
},
{
"Page": "/page-in-question"
}
],
"metrics": []
},
"session": {
"id": "062703E5-5E15-491A-AC75-2FE54EF03623",
"isFirst": false
}
}
}

最佳答案

稍微动态一点的解决方案是设置临时表:

WITH ATable AS (
SELECT
temp.internal.data.id as ID
,dimensions.ArrayValue.CategoryAction as CategoryAction
,dimensions.ArrayValue.SessionId as SessionId
,dimensions.ArrayValue.WebsiteVersion as WebsiteVersion
,dimensions.ArrayValue.PageSection as PageSection
,dimensions.ArrayValue.Category as Category
,dimensions.ArrayValue.Page as Page
FROM [analyticseventinputs] temp
CROSS APPLY GetElements(temp.[context].[custom].[dimensions]) as dimensions)

然后根据唯一键进行连接

FROM [analyticseventinputs] Input 
Left JOIN ATable CategoryAction on
Input.internal.data.id = CategoryAction.ID AND
CategoryAction.CategoryAction <> "" AND
DATEDIFF(day, Input, CategoryAction) BETWEEN 0 AND 5

相当烦人的一点是对 datediff 的要求,因为联接旨在组合 2 个数据流,但在这种情况下,您仅联接唯一键。所以我把它设置为一个较大的值5天。与其他解决方案相比,这实际上只能防止自定义参数未按顺序出现。

关于json - 使用流分析将自定义事件维度从 Application Insights 导出到 SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31528147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com