避免在查询中多次运行函数

时间:2017-07-26 23:38:43

标签: azure-application-insights ms-app-analytics

我在Application Insights中有以下查询,我在同一个查询中多次运行parsejson函数。

第一次调用后是否可以重用// where are we posting to? $url = 'http://foo.com/script.php'; // what post fields? $fields = array( 'field1' => $field1, 'field2' => $field2, ); // build the urlencoded data $postvars = http_build_query($fields); // open connection $ch = curl_init(); // set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars); // execute post $result = curl_exec($ch); // close connection curl_close($ch) 函数中的数据?现在我在查询中调用它三次。我试图看一次调用它是否会更有效。

parsejson()

1 个答案:

答案 0 :(得分: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