【问题标题】:Cannot query AppInsight log无法查询 AppInsight 日志
【发布时间】:2021-01-01 17:40:10
【问题描述】:

我正在努力创建 AppInsight 查询...

我想获取应用程序的启动次数并将其除以触发某个事件的次数(拼写检查器)。

实际上,我有 3 个应用程序都使用相同的拼写检查功能,我想看看每个应用程序中拼写检查的使用量是否相同。

//First, let's get the count of hasBeenUsed (how many times the application has been used) 
let app1Starts =
customEvents
| where timestamp > ago(30d)
| where name == 'hasBeenUsed';
| where customDimensions['payload.appId] == 'app1'
| summarize count(); 
//Now, let's get the count of how many times spellchecking has happened for that specific application
let spellCheckEvents =
customEvents
| where timestamp > ago(30d)
| where name == 'spellchecked';
| where customDimensions['payload.appId] == 'app1'
| summarize count();
//this is where I struggle
customEvents
| summarize app1Starts / spellCheckEvents    //HELP ME PLEASE

我收到错误消息

“summarize”运算符:无法解析名为“app1Starts”的标量表达式

如果我将最后一行从 summarize 更改为 extend,也会发生同样的情况

【问题讨论】:

    标签: azure azure-application-insights


    【解决方案1】:

    您可以在 let 语句中使用toscalar() 运算符。

    在您的情况下,查询应该是:

    //First, let's get the count of hasBeenUsed (how many times the application has been used) 
    let app1Starts =toscalar(
    customEvents
    | where timestamp > ago(30d)
    | where name == 'hasBeenUsed'
    | where customDimensions['payload.appId] == 'app1'
    | summarize count()); 
    
    //Now, let's get the count of how many times spellchecking has happened for that specific application
    let spellCheckEvents =toscalar(
    customEvents
    | where timestamp > ago(30d)
    | where name == 'spellchecked'
    | where customDimensions['payload.appId] == 'app1'
    | summarize count());
    
    //then you can use the following statement
    customEvents
    | extend c1=app1Starts/spellCheckEvents 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-09
      • 2011-05-06
      • 2011-06-05
      • 2019-05-19
      • 2022-10-15
      • 2013-07-19
      • 2015-06-03
      • 2023-04-06
      相关资源
      最近更新 更多