azure-application-insights - 如何使用 Asp.Net-Core HealthChecks 设置 Application Insights
问题描述
Asp.Net Core 发布了 2.2 版,并附带了 HealthChecks 功能。(阅读更多)。它的功能之一是将运行状况检查结果推送到 Azure Application Insights。但我还没有找到任何方法可以在 Azure 门户中查看这些结果。要发送结果,我使用以下扩展:
services.AddHealthChecks()
.AddSqlServer("...")
.AddApplicationInsightsPublisher();
有没有办法在 Application Insights 中查看这些运行状况检查报告?
编辑 1:我以官方github docs为例。
编辑 2:如果我转到 Azure 门户查询分析,我会看到以下结果:
查询requests
:
查询customEvents
这里:GET /health
是我的 healthCheck 端点。通过查询requests
日志,我可以查看健康检查是否失败,但我想查看有关每个健康检查的更多详细信息,而且我认为我不需要对此进行任何扩展,所以我不明白AddApplicationInsightsPublisher()
实际做了什么。
解决方案
目前发布者(HealthCheckPublisherHostedService)的注册存在问题,该问题将为 aspnet core 3 修复。目前的解决方法是手动正确注册类:
services.AddHealthChecks()
.AddApplicationInsightsPublisher();
// This is a hack to fix an issue with the AddApplicationInsightsPublisher() call above
services.TryAddEnumerable(ServiceDescriptor.Singleton(typeof(IHostedService), typeof(HealthCheckPublisherOptions).Assembly.GetType("Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckPublisherHostedService")));
推荐阅读
- windows - 为什么 Git Windows 提交合并,即使使用 merge.commit=no?
- github-api - application/vnd.github+json 媒体类型是什么?
- java - 单击菜单项时未打开活动
- javascript - 如何使用 MongoDB 上的 CREATE、PUT 和 DELETE 请求优化性能?
- javascript - 如何将动态值与 HTML 元素相关联?
- python - Codewars 剥离评论问题随机工作/不工作“尝试”测试
- node.js - ExpressJS:本地主机没有发送任何数据
- javascript - 未检测到 Express 中间件
- php - PHP cURL 取消订阅 PayPal 问题
- markdown - 在 Nuxt.js 中从其他内容目录的 markdown 文件中的前端生成动态路由