【问题标题】:Kusto query help for Condition filter条件过滤器的 Kusto 查询帮助
【发布时间】:2021-10-25 04:30:02
【问题描述】:

我正在编写一个 Kusto 查询来创建一个仪表板来显示 VM 的运行状况。 VM 名称、状态、模式、启用状态在 signgl kusto 表中可用

下面是列出虚拟机的查询

VM
| where VMName has "XYZ" 
| where  VMName !has "XYZ123"
| where VMName has_any ("s","t","u","v")

我需要再做 1 个过滤器,用于识别带有状态的 VM 并分配给变量,如下所示在此处输入代码

enabled = "mode =online & enabled =true"
disabled = "mode =offline & enabled =true"
total = enabled + disabled

从这里我将计算显示在仪表板中的已启用 VM 的总数和百分比。

但我不能使用运算符“where”来执行此操作。你能帮我吗,因为我被困在这里没有解决办法。感谢您的支持。

【问题讨论】:

    标签: azure-data-explorer kql


    【解决方案1】:

    您可以使用 summarizecountif() 函数,这是一个示例,假设您有一个名为 state 的列,其值为“online”和“offline”,还有一个列被称为“启用”或“禁用”的模式

    VM
    | where VMName has "XYZ" 
    | where  VMName !has "XYZ123"
    | where VMName has_any ("s","t","u","v")
    | summarize Total = count(), EnabledCount = countif(mode == "online" and state=="enabled"), DisabledCount= countif(mode == "offline" and state=="enabled")
    

    【讨论】:

    • 非常感谢。它对我有用,我能够完成查询。
    猜你喜欢
    • 2010-12-26
    • 1970-01-01
    • 2011-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多