HealthChecks icon indicating copy to clipboard operation
HealthChecks copied to clipboard

Url/Check association

Open drauly opened this issue 8 years ago • 6 comments

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

drauly avatar Nov 07 '17 12:11 drauly

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.

JuergenGutsch avatar Dec 06 '17 13:12 JuergenGutsch

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 avatar Dec 06 '17 21:12 CESARDELATORRE

@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 avatar Dec 08 '17 08:12 drauly

@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.

JuergenGutsch avatar Dec 08 '17 12:12 JuergenGutsch

For me it is very useful to have a "url/check" relationship

MiguelCosta avatar Jan 11 '18 15:01 MiguelCosta

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.

PehrGit avatar Sep 27 '18 10:09 PehrGit