【问题标题】:Rows to columns in azure data explorer (kusto)azure 数据资源管理器 (kusto) 中的行到列
【发布时间】:2021-08-24 12:57:34
【问题描述】:

我有一个简单的查询:

let startDate = ago(7d);
let endDate = now();
let all_logs = materialize(MyTable | where TIMESTAMP > startDate and TIMESTAMP < endDate | where EventName == "SessionResult");
all_logs
| summarize 
Total_Sessions = count(),
Successful_Sessions = countif(Successful == "True"),
Failed_Sessions = countif(Successful == "False")
| extend Success_Rate = round(100.0*Successful_Sessions/Total_Sessions, 2)

返回

如何将其更改为:

标签计数率

总会话数 98 100

Successful_session 96 97.96

Failed_session 2 2.04

最好不使用枢轴插件

【问题讨论】:

    标签: azure-data-explorer kql


    【解决方案1】:

    您可以尝试使用narrow() 插件:https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/narrowplugin

    例如:

    let T = materialize(
        MyTable 
        | where TIMESTAMP > startDate and TIMESTAMP < endDate
        | where EventName == "SessionResult")
        | summarize 
             Total_Sessions = count(),
             Successful_Sessions = countif(Successful == "True"),
             Failed_Sessions = countif(Successful == "False")
    )
    ;
    let total = toscalar(T | project total_sessions)
    ;
    T
    | evaluate narrow()
    | project Label = Column, Count = Value, Rate = round(100.0 * tolong(Value) / total, 2)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-09
      • 1970-01-01
      • 2021-06-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多