【问题标题】:Kusto query to get queued events from a tableKusto 查询以从表中获取排队事件
【发布时间】:2021-02-03 20:33:18
【问题描述】:

任何人都可以帮助从下表数据构建 kusto 查询:

ProcessName ProcessID TimeStamp Status
abc 101 11:45:06 Queued
xyz 102 11:45:51 Queued
abc 101 11:45:57 Progress
abc 101 11:47:28 Succeeded
abc 103 11:48:51 Queued
abc 103 11:49:57 Progress
abc 103 11:50:28 Succeeded

我想得到作为查询结果处于排队状态的xyz值,条件是超过5m处于排队状态。

这是我一直在尝试但没有成功的方法。

let Events = MyLogTable | where ... ;

Events
| where Status == "Queued"
| project ProcessName, ProcessId, StartTime=TimeStamp
| join (Events 
        | where Status !in ("InProgress","Succeeded")
        | project ProcessId) 
    on ProcessId
| where StartTime>ago(5m)
| project ProcessName, ProcessId, StartTime, Status

非常感谢任何帮助,在此先感谢。

【问题讨论】:

    标签: azure-data-explorer kql


    【解决方案1】:

    假设每个进程 ID 恰好有一条记录为 Status == Queued,这可能有效:

    let Events = datatable(ProcessName:string, ProcessID:int, TimeStamp:datetime, Status:string)
    [
        'abc', 101, datetime(2021-02-02 11:45:06), 'Queued',
        'xyz', 102, datetime(2021-02-02 11:45:51), 'Queued',
        'abc', 101, datetime(2021-02-02 11:45:57), 'Progress',
        'abc', 101, datetime(2021-02-02 11:47:28), 'Succeeded',
        'abc', 103, datetime(2021-02-02 11:48:51), 'Queued',
        'abc', 103, datetime(2021-02-02 11:49:57), 'Progress',
        'abc', 103, datetime(2021-02-02 11:50:28), 'Succeeded',
    ]
    ;
    Events
    | where Status == "Queued" and ago(5m) > TimeStamp
    | where ProcessID !in ((
        Events
        | where Status != "Queued"
        | project ProcessID
    ))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-28
      • 2021-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多