5

i have developed an ASP.NET Core 3.1 MVC Application with customized Health Check. It's perfectly working fine as shown below.

enter image description here

However, the UI is always empty as the /health-api always returns empty array. enter image description here

enter image description here

It's in ASP.NET 3.1 Core application which can be located at https://github.com/prawin2k/HealhCheckMVC/tree/master/HealhCheckMVC

.NET Core version - 3.1 (MVC) Healthchecks version - Latest Operative system: Windows Server 2016 Others: Visual Studio 2019

0

1 Answer 1

8

In my case the health checks UI itself not launching and crashing the .net core 3.1 web API application.

Error Message: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: HealthChecks.UI.Core.Notifications.IHealthCheckFailureNotifier Lifetime: Scoped ImplementationType: HealthChecks.UI.Core.Notifications.WebHookFailureNotifier': Unable to resolve service for type 'HealthChecks.UI.Core.Data.HealthChecksDb' while attempting to activate 'HealthChecks.UI.Core.Notifications.WebHookFailureNotifier'.)

Fix: Add any UI storage provider . In my case I have choosen AddInMemoryStorage()

Startup.cs

public void ConfigureServices(IServiceCollection services)
{
    ...
    
    services.AddHealthChecks() 
        .AddDbContextCheck<PollDbContext>() //nuget: Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore
        .AddApplicationInsightsPublisher(); //nuget: AspNetCore.HealthChecks.Publisher.ApplicationInsights

    services.AddHealthChecksUI() //nuget: AspNetCore.HealthChecks.UI
        .AddInMemoryStorage(); //nuget: AspNetCore.HealthChecks.UI.InMemory.Storage
        
    ...
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    ...
    
    app.UseHealthChecks("/healthcheck", new HealthCheckOptions
    {
        Predicate = _ => true,
        ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse //nuget: AspNetCore.HealthChecks.UI.Client
    });
    
    //nuget: AspNetCore.HealthChecks.UI
    app.UseHealthChecksUI(options =>
    {
        options.UIPath = "/healthchecks-ui";
        options.ApiPath = "/health-ui-api";
    });
    ...
}

appsettings.json

"HealthChecks-UI": {
    "DisableMigrations": true,
    "HealthChecks": [
        {
            "Name": "PollManager",
            "Uri": "/healthcheck"
        }
    ],
    "Webhooks": [
        {
            "Name": "",
            "Uri": "",
            "Payload": "",
            "RestoredPayload": ""
        }
    ],
    "EvaluationTimeOnSeconds": 10,
    "MinimumSecondsBetweenFailureNotifications": 60,
    "MaximumExecutionHistoriesPerEndpoint": 15
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.