2016-11-07 38 views
1

如果我正在使用分析查詢功能,是否可以根據自定義條件重新標記圖例?例如,我想根據它們的子類型對異常進行分類。例如,SQL異常可能會下降到超時,權限不足等。只有這樣,才能做到這一點,我發現是通過這樣的查詢:基於條件的App Insights Analytics重命名圖例

exceptions 
| where timestamp > ago(7d) and outerType contains "SqlException" 
| project 
    ['SqlException'] = outerType, 
    timestamp, 
    outerMethod 
| summarize count(['SqlException']) by bin(timestamp, 1d), outerMethod 
| render timechart 

麻煩的是傳說是相當「羅嗦」,是想知道我是否可以使用「case when」方法,並根據條件重新標記圖例(通過檢查文本)。雖然這可能會很慢,但如果有更有效的方法,請隨時提出替代方案。從查看API參考資料我找不到一個,但目前我對此有限的經驗。

回答

0

您可以使用iff關鍵字。

下面是一個例子:

exceptions 
| where timestamp > ago(7d) and outerType contains "SqlException" 
| project 
    ['SqlException'] = outerType, 
    timestamp, 
    outerMethod 
| extend reason = iff(outerMethod has "timeout", "timeout", "other") 
| summarize count(['SqlException']) by bin(timestamp, 1d), reason 
| render timechart