【发布时间】:2016-02-24 08:54:18
【问题描述】:
我们有一个 azure 云服务,可以将所有异常记录到 Azure Application Insights。我们已设置将所有异常连续导出到 azure 存储表。最重要的是,我们有 Azure 流分析,它从存储 blob 中提取数据并将其推送到 Azure SQL 数据库。现在,问题是我们无法将 Exception json 中的 ParsedStack 正确转换/格式化为 varchar(max),以便我们可以将其插入数据库。
这是我们使用的流分析查询 -
SELECT
CASE
WHEN GetArrayLength(A.basicException) > 0
THEN GetRecordPropertyValue(GetArrayElement(A.basicException, 0), 'assembly')
ELSE ''
END AS ExceptionAssembly
,
CASE
WHEN GetArrayLength(A.basicException) > 0
THEN GetRecordPropertyValue(GetArrayElement(A.basicException, 0), 'exceptionType')
ELSE ''
END AS ExceptionType
,
CASE
WHEN GetArrayLength(A.basicException) > 0
THEN GetRecordPropertyValue(GetArrayElement(A.basicException, 0), 'parsedstack')
ELSE ''
END AS ParsedStack
,A.context.device.id as DeviceId
,A.context.device.type as DeviceType
,A.context.device.browser as Browser
,A.context.device.browserVersion as BrowserVersion
,A.context.location.country as Country
,A.context.location.province as Province
,A.context.location.city as City
INTO
myexceptionsoutput
FROM myexceptionsinput A
SQL 表中的所有值都符合预期,但ParsedStack 列的值始终为Microsoft.EventProcessing.SteamR.Sql.ValueArray
编辑
添加Exception对象json(完整版很长,剪掉更清楚)-
"basicException": [{
"assembly": "Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"exceptionType": "System.ServiceModel.CommunicationObjectFaultedException",
"outerExceptionType": "System.ServiceModel.CommunicationObjectFaultedException",
"failedUserCodeAssembly": "Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"exceptionGroup": "System.ServiceModel.CommunicationObjectFaultedException at lambda_method",
"count": 1,
"outerExceptionMessage": "The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state."
},
{
"parsedStack": [{
"method": "System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage",
"assembly": "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"level": 0,
"line": 0
},
{
"method": "System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke",
"assembly": "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"level": 1,
"line": 0
},
{
"method": "System.IDisposable.Dispose",
"assembly": "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"level": 2,
"line": 0
}],
"hasFullStack": true,
"id": "22349146",
}],
"internal": {
"data": {
"id": "bd6f2355-ed02-4883-abb9-d8ed6ceba646",
"documentVersion": "1.61"
}
}
【问题讨论】:
-
A.basicException的类型是什么,是数组还是数组数组?我在下面的一个事件上尝试了下面的查询,它可以工作。您的查询类似,如果 A.basicException 是一个数组,它应该可以工作。事件:{"ArrayColumn":[{"Id":255},{"Id":215}],"NormalColumn":40,"DeviceId":"D2"} ASA 查询选择 NormalColumn,getarraylength(ArrayColumn) 时的情况> 0 然后 GetRecordPropertyValue(getarrayelement(ArrayColumn,0), 'Id') else ' ' end [Id], System.Timestamp [EventTimeStamp], DeviceId 从 iotInput 进入 tableOutput
-
@VigneshwaranChandramohan 我添加了 JSON 对象。 BasicException 这里是两个对象的数组。第二个对象同样有两个对象,第二个对象是 ParsedStack。当我看到 ParsedStack 是一个大小总是在变化的对象数组时,它变得更加复杂,基于异常的堆栈跟踪中的行
标签: azure-application-insights azure-stream-analytics cortana-intelligence