HealthChecks
HealthChecks copied to clipboard
Url/Check association
Hello,
It seems their is no way to associate an url with a specific check
/url1 => check1 /url2 => check2
Is it something planned ?
Thank you
Does it really make sense? I'm just curious. I don't have an idea yet about an use case. Usually you want to have one URL the see the overall health of your entire application. don't you? What is your idea about that?
Maybe one use case: Creating one central health check app, that checks many different applications.
I might be wrong or misunderstood you, but I think we're precisely doing that in the WatchDog app we have at eShopOnContainers: https://github.com/dotnet-architecture/eShopOnContainers/blob/dev/src/Web/WebStatus/Startup.cs
See the code like:
services.AddHealthChecks(checks =>
{
var minutes = 1;
if (int.TryParse(Configuration["HealthCheck:Timeout"], out var minutesParsed))
{
minutes = minutesParsed;
}
checks.AddUrlCheckIfNotNull(Configuration["OrderingUrl"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheckIfNotNull(Configuration["BasketUrl"], TimeSpan.Zero); //No cache for this HealthCheck, better just for demos
checks.AddUrlCheckIfNotNull(Configuration["CatalogUrl"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheckIfNotNull(Configuration["IdentityUrl"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheckIfNotNull(Configuration["LocationsUrl"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheckIfNotNull(Configuration["MarketingUrl"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheckIfNotNull(Configuration["PaymentUrl"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheckIfNotNull(Configuration["mvc"], TimeSpan.Zero); //No cache for this HealthCheck, better just for demos
checks.AddUrlCheckIfNotNull(Configuration["spa"], TimeSpan.Zero); //No cache for this HealthCheck, better just for demos
});
@CESARDELATORRE , I think AddUrlCheckIfNotNull is to check http dependencies
@JuergenGutsch, I have a monitoring system that can check several healthcheck. Eg:
/hc/simple => used by LB, if it fails, make service out of pool /hc/full => used by service monitoring, provide a more precise check (some dependencies should not make the service out of pool, but indicate that the service is in a degraded state)
However, I can do it manually
@drauly that scenario makes sense. If UseHealthChecks woudl be on IApplicationBuilder level instead on the WebHostBuilder level, it would be possible to use multiple paths.
For me it is very useful to have a "url/check" relationship
Another reason this would be useful is because Kubernetes offers a separate Liveness and Readiness probe. They are separate and serve different purposes. In our case we want to check if the application is in a failed state in the Liveness Probe, and we want to check if the database can connect to the necessary dependencies in the Readiness Probe. Supporting multiple endpoints with separate checks would be very useful for us.