You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Application Insights分析中,如何查询特定异常影响用户的占比?

如何计算特定异常影响用户的占比?

Got it, let's break this down to get the percentage of users impacted by each exception relative to your total user base. You can combine your two existing queries into a single, streamlined query using the toscalar() function to pull in the total user count directly into your exception stats.

Here's the complete query that does exactly what you need:

let totalUsers = toscalar(
    customEvents 
    | where application_Version == "xyz" 
    | summarize dcount(user_Id)
);
exceptions 
| where application_Version == "xyz" 
| summarize 
    count_=count(itemCount), 
    impactedUsers=dcount(user_Id),
    impactedUsersPercentage = iif(totalUsers == 0, 0.0, round(todouble(impactedUsers) / totalUsers * 100, 2))
by problemId, type, method, outerMessage, innermostMessage 
| order by impactedUsersPercentage desc

Quick breakdown of what's happening here:

  • let totalUsers = toscalar(...): This creates a variable that stores your total user count as a single scalar value. The toscalar() function lets you use this number seamlessly in the main exception query.
  • impactedUsersPercentage calculation: We convert counts to doubles to avoid integer division issues, then compute the percentage. The iif(totalUsers == 0, 0.0, ...) handles edge cases where there might be no total users (prevents division-by-zero errors).
  • round(..., 2): Keeps the percentage to 2 decimal places for readability—feel free to adjust this number if you want more or less precision.
  • order by impactedUsersPercentage desc: Sorts results from the most impactful exceptions (by percentage) to the least. You can switch back to impactedUsers if you prefer sorting by raw user count instead.

If you need to adjust any part—like adding more filters, changing rounding, or including extra fields—just tweak the query accordingly!

内容的提问来源于stack exchange,提问作者kopieczek.dev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 08:09:54