首页 > 解决方案 > Kusto 查询中的案例语句

问题描述

我的表中有一大串代码,我已经使用 != 将其中一些代码静音/排除了

我想检查特定错误代码的条件,如下所示。并且还想要我在表格中的其他代码。

exceptions
| extend A_= tostring(customDimensions.A)
| extend B_ = tostring(customDimensions.B)
| where B_ != '21000' //exclude
| where B_ != '30000' //exclude
| where B_ != '40000' //exclude
| where B_ == "80000" 
    and A_ != "abcd" 
    and A_ != "wxyz"

将 B_ == "80000" 与 "and" 运算符一起使用的问题是,它只输出代码 80000 的列表,其中没有我想要的那两个字符串。但我也想输出我没有在查询中排除的其他代码。

到目前为止,我已经尝试使用如下的 case 语句;

| where error_code_ != case(B_ != "80000", A_ != "abcd" , A_ != "wxyz")

但这并没有像我预期的那样工作。不确定查询有什么问题,或者是否有更好的解决方案。

标签: azure-log-analyticsazure-data-explorerkql

解决方案


只需使用or运算符:

exceptions
| extend A_= tostring(customDimensions.A)
| extend B_ = tostring(customDimensions.B)
| where B_ != '21000' //exclude
| where B_ != '30000' //exclude
| where B_ != '40000' //exclude
| where (B_ == "80000" and A_ != "abcd" and A_ != "wxyz") or B_ !="80000"

推荐阅读