在 kusto 中从计数运算符中查找百分比结果

Finding percentages from the count operator results in kusto

我有两个查询,它们查找使用计数运算符的不同出现次数的总数。然后我希望能够显示这些故障的不同发生总数的百分比。所以我尝试用 DistinctRB 除以 Distinct Faults 得到一个比率。

let DistinctFaults = materialize (FaultView
|distinct ha, Ba, ga
|count);
let DistinctRB = materialize (FaultView
|where RB =~ "yes"
|distinct ha, Ba,ga
|count);
print  FaultRB / DistinctFaults

你可以试试这个(使用 toscalar()):

let DistinctFaults = toscalar(
    FaultView
    | distinct ha, Ba, ga
    | count
);
let DistinctRB = toscalar(
    FaultView
    | where RB =~ "yes"
    | distinct ha, Ba, ga
    | count
);
print result = FaultRB / DistinctFaults

或者,如果估计非重复计数(使用 dcountif())是一个选项:

FaultView
| summarize result = dcountif(strcat_delim("_", ha, Ba, ga), RB =~ "yes") / 
            dcount(strcat_delim("_", ha, Ba, ga))