我們有一個Azure雲服務,它將所有異常記錄到Azure Application Insights。我們已經設置了對azure存儲表的所有例外的連續導出。最重要的是,我們有Azure Stream Analytics,它從存儲blob中提取數據並將其推送到Azure SQL數據庫。現在,問題是我們無法從異常json轉換/格式ParsedStack
到varchar(max),因此我們可以將它插入數據庫。流分析查詢Azure Application Insights的異常ParsedStack連續導出
這是我們使用的流分析查詢 -
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') 別的 '' 端[ID], System.Timestamp [EventTimeStamp], DEVICEID 成 tableOutput from iotInput –
@Vigneshwa ranChandramohan我添加了JSON對象。這裏的BasicException是兩個對象的數組。第二個對象又有兩個對象,第二個對象是ParsedStack。當我看到ParsedStack是一個大小始終在變化的對象數組時,它變得更加複雜,這是基於異常 –