2016-11-07 34 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