Skip to content
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

HealthCheck UI is empty #603

Closed
RagnarGothur opened this issue Aug 5, 2020 · 3 comments
Closed

HealthCheck UI is empty #603

RagnarGothur opened this issue Aug 5, 2020 · 3 comments

Comments

@RagnarGothur
Copy link

RagnarGothur commented Aug 5, 2020

Hello!
In my case the "/health-api" works as expected: returns json with healthcheck results. But there are no any healthcheck results on "/health-ui" because the "/health-ui-api" returns an empty array.
Configuration examples:

services
                .AddHealthChecks()
                .AddCheck("Self", () => HealthCheckResult.Healthy())
                .AddNpgSql(
                    name: "Database",
                    npgsqlConnectionString: Configuration.GetValue<string>("ConnectionString"),
                    healthQuery: "SELECT 1;",
                    failureStatus: HealthStatus.Degraded
                )
                .Services
                .AddHealthChecksUI()
                .AddInMemoryStorage(options =>
                {
                    options.EnableDetailedErrors();
                });


app
                .UseRouting()
                .UseEndpoints(config =>
                {
                    config.MapHealthChecks("/health-api", new HealthCheckOptions
                    {
                        Predicate = _ => true,
                        ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
                    });

                    config.MapHealthChecksUI(setup =>
                    {
                        setup.UIPath = "/health-ui";
                        setup.ApiPath = "/health-ui-api";
                    });

                    config.MapDefaultControllerRoute();
                });

All of the packages have 3.1.1 version.
How can I fix it?

@RagnarGothur
Copy link
Author

RagnarGothur commented Aug 6, 2020

Finally got it working by changing code like this:
.AddHealthChecksUI(settings => settings.AddHealthCheckEndpoint("checks", "/health-api")).
But I still wonder why the code sample from UIAndApiCustomization didn't work for me. Can someone explain that unclear behavior please?

@Odonno
Copy link
Contributor

Odonno commented Aug 17, 2020

I have the same result you have. Seems like the code sample is broken at the moment.

But, to me, it feels more natural and logic to specify the endpoints yourself. If no endpoint provided, then no result (empty UI). So, the default behavior would be to do this:

services.AddHealthChecksUI(settings =>
{
    settings.AddHealthCheckEndpoint("Self", "/healthz");
});

@CarlosLanderas
Copy link
Contributor

CarlosLanderas commented Sep 2, 2020

@RagnarGothur , I see you are using AddHealthChecks without the setup configuration,that means that your settings must be specified in appsettings, secrets or environment variables, where you should specify the target healthcheck endpoints.

you can also specify the remote endpoints as @Odonno says:

services.AddHealthChecksUI(settings =>
{
    settings.AddHealthCheckEndpoint("endpoint1", "/healthz");
});

Could you show your appsettings configuration?. They should have /health-api segment that you specified in MapHealthChecks method

EDIT: In your second answer it's working because you properly specified the /health-api. If you dont use the setup method you need to configure the healthcheck in appsettings like this:

"HealthChecksUI": {
    "HealthChecks": [
      {
        "Name": "Http and UI on single project with customizations-1",
        "Uri": "/health-api"
      }
    ],

The UIAndApiCustomization is working fine for me:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants