2016-11-23 52 views
0

我在應用程序的見解分析聚集在應用洞察分析的標量處理

let total = exceptions 
| where timestamp >= ago(7d) 
| where problemId contains "Microsoft.ServiceBus" 
| summarize sum(itemCount); 

let nullContext = exceptions 
| where timestamp >= ago(7d) 
| where problemId contains "Microsoft.ServiceBus" 
| where customDimensions.["SpecificTelemetry.Message"] == "HttpContext.Current is null" 
| summarize sum(itemCount); 

let result = iff(total == nullContext, "same", "different"); 
result 

此查詢,但我得到這個錯誤

無效的關係運算符

我很驚訝,因爲昨天用相同的代碼(據我記得),我得到一個不同的錯誤,說支票的兩面都需要標量,但我的理解是聚合即使它顯示一個值(在sum_countItem下)也不是標量。但是找不到改變它的方法,或者現在擺脫這項工作。

謝謝

回答

1

幾個問題。 首先 - 無效的關係運算符可能是由於let語句之間的空行造成的。 AI Analytics允許您在同一窗口中編寫多個查詢,並使用空行來分隔這些查詢。因此,爲了將所有語句作爲單個查詢運行,您需要消除空行。

關於「關係運算符的左右側必須是標量」的錯誤 - 「彙總」運算符的結果是一個表而不是標量。它可以包含一行/一列或多個(如果在總結中添加「by」子句,會發生什麼情況)。 要實現您想要做的事情,您可能需要使用如下單個查詢:

exceptions 
| where timestamp >= ago(7d) 
| where problemId contains "Microsoft.ServiceBus" 
| extend nullContext = customDimensions.["SpecificTelemetry.Message"] == "HttpContext.Current is null" 
| summarize sum(itemCount) by nullContext