【应用程序见解 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
当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!
分类:
【Azure 应用程序见解】
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?