【应用程序见解 Application Insights】在Application Insights中通过自定义查询结果定义指标并显示在Dashboard中

简介: 【应用程序见解 Application Insights】在Application Insights中通过自定义查询结果定义指标并显示在Dashboard中

问题情形

通过Application Insights收集到指标数据后,如Request,Trace,Exception。但是默认的Insights图表不能满足业务的需求,需要自定义相应的类SQL语句并制作图表以便直观的显示,避免每次都需要重新查询数据并转换为图表。

类SQL的查询语句在Applicaiton Insights示例为:

// Response time trend 
// Chart request duration over the last 12 hours. 
requests
| where timestamp > ago(12h) 
| summarize avgRequestDuration=avg(duration) by bin(timestamp, 10m) // use a time grain of 10 minutes
| render timechart

// Operations performance 
// Calculate request count and duration by operations. 
requests
| summarize RequestsCount=sum(itemCount), AverageDuration=avg(duration), percentiles(duration, 50, 95, 99) by operation_Name // you can replace 'operation_Name' with another value to segment by a different property
| order by RequestsCount desc // order from highest to lower (descending)


// Top 10 countries by traffic 
// Chart the amount of requests from the top 10 countries. 
requests
| summarize CountByCountry=count() by client_CountryOrRegion
| top 10 by CountByCountry
| render piechart


// Top 3 browser exceptions 
// What were the highest reported exceptions today? 
exceptions
| where notempty(client_Browser) and client_Type == 'Browser'
| summarize total_exceptions = sum(itemCount) by problemId
| top 3 by total_exceptions desc

// Failed requests – top 10 
// What are the 3 slowest pages, and how slow are they? 
requests
| where success == false
| summarize failedCount=sum(itemCount) by name
| top 10 by failedCount desc
| render barchart

// Failed operations 
// Calculate how many times operations failed, and how many users were impacted. 
requests
| where success == false
| summarize failedCount=sum(itemCount), impactedUsers=dcount(user_Id) by operation_Name
| order by failedCount desc


操作步骤

Application Insights提供了非常简单的办法来完成制作图表的步骤,只需要在Logs页面中,按照上面的类SQL语句写好后,点击右上角的固定到仪表盘(Pin To Dashboard)即可。

 

参考资料:

创建诊断设置以在 Azure 中收集资源日志和指标:https://docs.azure.cn/zh-cn/azure-monitor/platform/diagnostic-settings

相关文章
|
自然语言处理 fastjson Java
记一次细思极恐的FastJson差点引发的大面积故障
作者记录了一次FastJson差点引发的大面积故障的排查过程和解决方案。
|
机器学习/深度学习 数据采集 索引
探索数据的维度:多元线性回归在实际应用中的威力
探索数据的维度:多元线性回归在实际应用中的威力
|
开发框架 .NET API
【应用程序见解 Application Insights】Application Insights 使用 Application Maps 构建请求链路视图
【应用程序见解 Application Insights】Application Insights 使用 Application Maps 构建请求链路视图
288 0
|
SQL Go 数据库
SQLServer 学习笔记之超详细基础SQL语句 Part 9
SQLServer 学习笔记之超详细基础SQL语句 Part 9
290 0
|
机器学习/深度学习
【阿旭机器学习实战】【14】决策树回归模型实战:对美国波士顿房价进行分析预测
【阿旭机器学习实战】【14】决策树回归模型实战:对美国波士顿房价进行分析预测
|
人工智能 达摩院 算法
走出舒适圈,从来都不简单
【为你揭开阿里大牛的神秘面纱】专访达摩院高级算法专家菲莹
走出舒适圈,从来都不简单
|
8天前
|
域名解析 人工智能 Linux
|
18天前
|
Linux Go 开发工具
手机上跑 DeepSeek 智能体:开源安卓客户端 DSH Go 安装与使用指南
DSH Go 是一款开源安卓客户端,将 DeepSeek Harness 智能体引擎装进手机:免 Root、免 Termux,一键安装即用;支持本机运行(内置 Ubuntu+Node.js)或远程接管电脑会话;具备插话打断、过程折叠、屏幕操控、端到端加密分享等特色功能,真正实现智能体“口袋化”。
17089 62
|
16天前
|
人工智能
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
进不去 Antigravity 或 Gemini,提示所在地区不可用?三步查清 Google 账号关联地区、官方更正表单理由选法与改区注意事项。
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
|
2天前
|
人工智能 安全 网络安全