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

HealthChecksUI not reading settings from appsettings.json #297

Closed
ciceroneves opened this issue Oct 7, 2019 · 3 comments
Closed

HealthChecksUI not reading settings from appsettings.json #297

ciceroneves opened this issue Oct 7, 2019 · 3 comments

Comments

@ciceroneves
Copy link

ciceroneves commented Oct 7, 2019

Hi,
I have followed the instructions on how to setup health checks and got HealthChecksUI running

The health checks are working fine and the UI also loads ok. The issue is that it does not show any of my health checks.

The only way I found to make it work, was to specifically deckare the endpoint the UI should call when adding it in ConfigureServices.

public void ConfigureServices(IServiceCollection services)
{
   services.AddHealthChecksUI("healthchecksdb", settings => settings.AddHealthCheckEndpoint("My health checks", "http://localhost:58811/healthz"));
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime applicationLifetime)
{
    app.UseHealthChecks("/healthz",
       new HealthCheckOptions()
       {
         Predicate = _ => true,
         ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
       });

    app.UseHealthChecksUI();
}

I would like to know why adding the UI settings to my appsettings.json does not work. See below the config I currently have in appsettings.json

{
  "HealthChecks-UI": {
    "HealthChecks": [
      {
        "Name": "My health checks",
        "Uri": "http://localhost:58811/healthz"
      }
    ],
    "EvaluationTimeInSeconds": 90,
    "MinimumSecondsBetweenFailureNotifications": 60
  }
}

I am using the nuget package AspNetCore.HealthChecks.UI version 2.2.35 in an ASP.Net Core project targeting the .Net Framework 4.7.2
Am I missing something?

@CarlosLanderas
Copy link
Contributor

Hello @ciceroneves
I can't see the app.UseHealthChecksUI line in your code.
UseHealthChecksUI is the method that wires the middlewares and binds the configurations.

@ciceroneves
Copy link
Author

Hello @ciceroneves
I can't see the app.UseHealthChecksUI line in your code.
UseHealthChecksUI is the method that wires the middlewares and binds the configurations.

Hey @CarlosLanderas,
Thanks for taking time to look into that.
I am using that line in my code. Only forgot to include it in the code snippet.
I have edited the question and added the line.

@CarlosLanderas
Copy link
Contributor

CarlosLanderas commented Oct 22, 2019

@ciceroneves, I've just tested the UIAndApiCustomization repository sample with your settings and it works just fine.
Please, Use that sample to test it and adjust your project.

Remember you can use HealthChecks-UI or HealthChecksUI settings key. The last one if the newest one to avoid problems with environment variables configuration

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

2 participants