【发布时间】:2022-08-05 17:29:28
【问题描述】:
我在 Azure Application Insights 工作簿中使用以下 Kusto 查询来获取满意用户、容忍用户和沮丧用户的数量。
let apdexThreshhold = toint(1000);
let apdexData = pageViews
| where timestamp > ago(7d)
| where name in (\'*\') or \'*\' in (\'*\')
| extend success = columnifexists(\'success\', true)
| extend Failure = iff(\'ConsiderFailures\' == \'ConsiderFailures\' and success == false, 1, 0)
| extend InterestingDimension = iff(isempty(name) == true, \'Unknown\', name)
| where InterestingDimension in (\'*\') or \'*\' in (\'*\')
| summarize AverageDuration = avg(duration), Failures = sum(Failure) by user_Id, InterestingDimension
| extend UserExperience = case(AverageDuration <= apdexThreshhold, \'Satisfied\', AverageDuration <= 4 * apdexThreshhold, \'Tolerating\', \'Frustrated\')
| extend UserExperience = case(Failures > 0, \"Frustrated\", UserExperience)
| summarize
Satisfied = countif(UserExperience == \'Satisfied\'),
Tolerating = countif(UserExperience == \'Tolerating\'),
Frustrated = countif(UserExperience == \'Frustrated\'),
Total = count()
by InterestingDimension
| project
InterestingDimension,
[\"Satisfied Users\"] = Satisfied,
[\"Tolerating Users\"] = Tolerating,
[\"Frustrated Users\"] = Frustrated,
[\"Apdex Score\"] = round((Satisfied + (Tolerating / 2.0)) / Total, 2),
Total
| extend Relevance = iff([\"Apdex Score\"] == 0, pow(Total, 1.6), Total / [\"Apdex Score\"])
| project-rename Users = Total
| order by Relevance desc
| project-away Users, Relevance;
apdexData
| extend [\"Apdex Interpretation\"] = case([\"Apdex Score\"] <= 0.5, \'⛔ Unacceptable\', [\"Apdex Score\"] <= 0.7, \'⚠️ Poor\', [\"Apdex Score\"] <= 0.85, \'⚠️ Fair\', [\"Apdex Score\"] <= 0.94, \'✔️ Good\', \'✔️ Excellent\')
| project
Values = InterestingDimension,
[\"Apdex Score\"],
[\"Apdex Interpretation\"],
[\"Satisfied Users\"],
[\"Tolerating Users\"],
[\"Frustrated Users\"]
上面的查询返回结果没有任何问题。但是,只要没有数据,此查询就会返回一条文本消息,上面写着“没有结果”。但我想在每列中显示一行,默认值为“0”。
例子:
更新:
let emptyRow = datatable( Values: string, [\"Apdex Score\"]: double, [\"Apdex Interpretation\"]: string, [\"Satisfied Users\"]:long, [\"Tolerating Users\"]: long, [\"Frustrated Users\"]: long) [ \"0\", 0, \"0\", 0, 0, 0] ;
<Above Query>
// add empty row
| union (emptyRow)
| order by [\"Apdex Interpretation\"] desc
上面的查询添加了空行,即使在结果的情况下也是如此。我尝试使用以下代码行更新上述查询,以仅在没有结果的情况下添加空行。但它仍然没有按预期工作。
let T = apdexData
| where Values!=null
| project
Values = InterestingDimension,
[\"Apdex Score\"],
[\"Apdex Interpretation\"],
[\"Satisfied Users\"],
[\"Tolerating Users\"],
[\"Frustrated Users\"];
let T_has_records = toscalar(T | summarize count() > 0);
union
(T | where T_has_records == true),
(emptyRow | where T_has_records == false)
标签: azure azure-application-insights kusto-explorer azure-monitor-workbooks