【问题标题】:Avoid running a function multiple times in a query避免在查询中多次运行函数
【发布时间】:2017-07-26 23:38:42
【问题描述】:

我在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

【问题讨论】:

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


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 2015-02-16
      • 2016-01-23
      • 1970-01-01
      • 2022-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-05
      • 1970-01-01
      相关资源
      最近更新 更多