2017-07-26 58 views
0

我在Application Insights中有以下查詢,我在同一個查詢中多次運行parsejson函數。避免在查詢中多次運行函數

是否有可能在第一次調用後重用parsejson()函數中的數據?現在我在查詢中調用了三次。我試圖看看是否只是一次調用它可能會更有效率。

EventLogs 
| where Timestamp > ago(1h) 
     and tostring(parsejson(tostring(Data.JsonLog)).LogId) =~ '567890' 
| project Timestamp, 
    fileSize = toint(parsejson(tostring(Data.JsonLog)).fileSize), 
    pageCount = tostring(parsejson(tostring(Data.JsonLog)).pageCount) 
| limit 10 

回答

1

您可以使用extend爲:

EventLogs 
| where Timestamp > ago(1h) 
| extend JsonLog = parsejson(tostring(Data.JsonLog) 
| where tostring(JsonLog.LogId) =~ '567890' 
| project Timestamp, 
    fileSize = toint(JsonLog.fileSize), 
    pageCount = tostring(JsonLog.pageCount) 
| limit 10