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

Not clear how to consume the UI #2303

Open
chivandikwa opened this issue Oct 7, 2024 · 1 comment
Open

Not clear how to consume the UI #2303

chivandikwa opened this issue Oct 7, 2024 · 1 comment

Comments

@chivandikwa
Copy link

chivandikwa commented Oct 7, 2024

EDIT - Resolved

Not clear how to consume the UI

What happened:

I am unable to setup the health check UI and even after browsing open and closed issues, the answer is not clear.

I have health checks setup in my startup, sample

services.AddHealthChecks()
            .AddApplicationStatus(name: "Application Status")
            ....

I then setup the UI as documented

services
            .AddHealthChecksUI()
            .AddInMemoryStorage();

The same for the rest of the bootstrapping

        app.UseHealthChecks("/healthz", new HealthCheckOptions
        {
            Predicate = _ => true,
            ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
        });

        app
            .UseRouting()
            .UseEndpoints(config => config.MapHealthChecksUI());

Now if I leave the default for MapHealthChecksUI, the UI is empty even though /healthz returns data formatted for the UI.

If I then update the Api URL to point to /healthz then I get a console error saying map is not a function and nothing is loaded in the UI again.

What is the correct way to configure the UI

What you expected to happen:

To be able to get the UI to show the health checks.

Thanks for looking into this

Environment:

  • .NET Core version: . NET 8
  • Healthchecks version: 8.0.1
  • Operative system: Windows
@chivandikwa
Copy link
Author

Ok, so finally found a working answer

        services
            .AddHealthChecksUI(opt =>
            {
                opt.AddHealthCheckEndpoint("API", "/api/health");
            })
            .AddInMemoryStorage();

        services
            .AddHealthChecks()
            .AddApplicationStatus(name: "Application Status")
           ...

        app.UseHealthChecks("/api/health", new HealthCheckOptions
        {
            Predicate = _ => true,
            ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
        });

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapHealthChecksUI(opt =>
            {
                opt.UIPath = "/healthcheck-ui";
            });
        });

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

1 participant