AspNetCore Health Check UI endpoint resolving

555 Views Asked by At

in my .NET5 API I added Health Check UI. In ConfigureServices:

services.AddHealthChecks();
services.AddHealthChecksUI(opt =>
        {
            opt.SetEvaluationTimeInSeconds(15); //time in seconds between check
            opt.MaximumHistoryEntriesPerEndpoint(60); //maximum history of checks
            opt.SetApiMaxActiveRequests(1); //api requests concurrency
            opt.AddHealthCheckEndpoint("Service", "/health");
        }).AddInMemoryStorage();

And finally in Configure:

    app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapHealthChecks("/health", new HealthCheckOptions
                {
                    Predicate = _ => true,
                    ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
                });
                endpoints.MapHealthChecksUI();
            });

But reported status is invalid and with JSON error: HealthCheckUI

Whilst going manually to endpoint (/health) I get response:

{"status":"Healthy","totalDuration":"00:00:00.0032081","entries":{}}

What I am doing wrong here? :/ I tried to look up this issue, but no solution fixed my issue. Do I really have to use absolute URLs for this?

GetHealthReport threw an exception when trying to get report                                                  
from /health configured with name Service.
Newtonsoft.Json.JsonReaderException: Unexpected character 
encountered while parsing value: <. Path '', line 0, position 0
0

There are 0 best solutions below