beewest
beewest

Reputation: 4846

Configure HealthChecksUI for AspNetCore WebApi

I am setting up the HealthCheckUI for the ASPNETCore web api (.Net Core 3.1). However http://localhost:1234/healthchecks-ui keeps calling the default api http://localhost:1234/healthchecks-api instead of http://localhost:1234/health as configured.

The /health returns JSON data as expected and /healthchecks-api returns [].

enter image description here

Any idea please?

Setup:

public void ConfigureServices(IServiceCollection services){
   ...
   services.AddHealthChecksUI(setupSettings: setup=> 
            {
                setup.SetEvaluationTimeInSeconds(15); //time in seconds between check
                setup.MaximumHistoryEntriesPerEndpoint(60); //maximum history of checks
                setup.SetApiMaxActiveRequests(1); //api requests concurrency

                setup.AddHealthCheckEndpoint("api", "/health"); //map health check api
            })
            .AddInMemoryStorage();
}

and

public void Configure(IApplicationBuilder app){
   ...
   app.UseEndpoints(endpoints =>
            {
                endpoints.MapHealthChecks("/health", new HealthCheckOptions { ResponseWriter = HealthCheckResponseWriter.WriteAsync });
                endpoints.MapHealthChecksUI();

            });
}

Upvotes: 0

Views: 819

Answers (1)

beewest
beewest

Reputation: 4846

My HealthCheck JSON is not good format. Working fine with the default UIResponseWriter:

endpoints.MapHealthChecks("/health", new HealthCheckOptions { ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse });

Upvotes: 1

Related Questions