servicehealth-monitoringhealth-checkdotnet-aspire

Aspire 9.1 Service returns Unhealthy, but Aspire Dashboard does not reflect the state


For testing purposes, I changed the code line in the aspire template project from .AddCheck("self", static () => HealthCheckResult.Healthy(), ["live"]); to .AddCheck("self", static () => HealthCheckResult.Unhealthy(), ["live"]);

I wanted to know how this would reflect on the Dashboard. To my surprise, all Services are flagged green. If I call the /health or /alive URL the service returns Unhealthy as expected. So how can the Dashboard not show this?

The only thing I could see that happened is that if I call /alive, I see an error log at the service mentioning that it is called in an unhealthy state.


Solution

  • Sorry,

    I totaly forgot about this post because I got my answere by the aspire team directly.

    The health check shown in aspire does only concern the pots. However you can add the http health checks easy in the Host project. All you have to do is to Change

    IResourceBuilder<ProjectResource> weatherService = builder.AddProject<WeatherService>("weatherservice");
    

    to

    IResourceBuilder<ProjectResource> weatherService = builder.AddProject<WeatherService>("weatherservice")
                                                              .WithHttpsHealthCheck("/health");
    

    Now your service will reflect the health state returned by the /health path too.