// Web Application Builder code goes here
builder.Services.AddHealthChecks()
.AddCheck<BrighterServiceActivatorHealthCheck>("Brighter", HealthStatus.Unhealthy);
var app = builder.Build();
app.UseEndpoints(endpoints =>
{
endpoints.MapHealthChecks("/health");
endpoints.MapHealthChecks("/health/detail", new HealthCheckOptions
{
ResponseWriter = async (context, report) =>
{
var content = new
{
Status = report.Status.ToString(),
Results = report.Entries.ToDictionary(e => e.Key,
e => new
{
Status = e.Value.Status.ToString(),
Description = e.Value.Description,
Duration = e.Value.Duration
}),
TotalDuration = report.TotalDuration
};
context.Response.ContentType = "application/json";
await context.Response.WriteAsync(JsonSerializer.Serialize(content, JsonSerialisationOptions.Options));
}
});
});
app.Run();
The /health endpoing will return a Status 200 with the Body of the Health status (i.e. Healthy)
The /health/detail endpoint will return a detailed response with all of your information for example:
{
"status": "Healthy",
"results": {
"Brighter": {
"status": "Healthy",
"description": "21 healthy consumers.",
"duration": "00:00:00.0000132"
}
},
"totalDuration": "00:00:00.0029747"
}
In the event on a Degraded status the /health/details page can be used to find out which Dispatchers have failed pumps