-
Notifications
You must be signed in to change notification settings - Fork 763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publishing HealthCheck report to Application insights #72
Comments
This is a configuration sample on But you need also configure Application Insights in your project, you have UseApplicationInsights and the instrumentation key configured? I try to create a complete sample this afternoon using AI with a preconfigured Instrumentation Key, ok? |
There is currently an issue with the registration of the publisher (HealthCheckPublisherHostedService) which will be fixed for 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"))); See : dotnet/extensions#639 |
Hi @NatMarchand This issue apply only if you have other hosted service registered, I don't now if this is related with this issue. |
Can you try add the instrumentation key on AddApplicationInsightsPublisher method and check if work well? |
I modify the sample "HealthChecks.Sample" to include all necesary to work with ApplicationInsightPublisher, can you checkout? You only need to modify the appsettings.json and set your instrumentation key. When the hosted service work this send custom metrics to AI, you can view this custom metrics on Metrics section P.S: Be patient because custom metric don't are visible inmediatly!! Hope this help |
Thanks for quick reply. I had application insights configured, in fact I also use hosted services in my project and the workaround provided by @NatMarchand helped (Thank you!). I can see AspNetCoreHealthCheck custom events now. Is it possible to also send a name of failing health check to app insights? This would allow to have all information in single place without need of using HealthCheckUI |
I set up health checks as per
Readme
:If I navigate to my
/health
endpoint I can see status of health check. But if I go to Azure portal and check application insights logs I cannot see any custom events related to health checks. Is there any example/tutorial/whatsoever on howAddApplicationInsightsPublisher()
extension should behave? I also posted a question to stack overflow, but no luck there.The text was updated successfully, but these errors were encountered: