-
Notifications
You must be signed in to change notification settings - Fork 0
Health
LittleBlocks supports health check configuration and the API can be configured to enable detail health check in the following cases:
- Dependencies to external API's
- SQL/NoSQL connectivity
- DataContext Validity
A full list of out of the box health checks and publishers are available at https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks#Health-Checks. Also, a further configuration can be made for UI and customization https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks
The health check is automatically available on the start but can be configured to add a proper set of health checks to the API. The health endpoint is automatically available in "/health" which return the status of each dependency (health check) in JSON format.
Here is an example:
services.BootstrapApp<Startup>(Configuration,
app => app
.AddConfigSection<Clients>()
.AndSection<Section1>()
.AndSection<Section2>()
.HandleApplicationException<TemplateApiApplicationException>()
.ConfigureCorrelation(m => m.AutoCorrelateRequests())
.ConfigureHealthChecks(c =>
{
c.AddUrlGroup(new Uri("http://www.google.com"), HttpMethod.Get, "google");
c.AddUrlGroup(new Uri("http://www.Microsoft.com"), HttpMethod.Get, "microsoft");
c.AddUrlGroup(new Uri("http://www.littleblocks.com"), HttpMethod.Get, "littleblocks");
c.AddSeqPublisher(setup =>
{
setup.Endpoint = Configuration["seq:ServerUrl"];
setup.ApiKey = Configuration["seq:ApiKey"];
});
})Using the above code and browsing to "/health" endpoint, the following output will be the returned which indicates the health state of each dependency:
{
"status": "Healthy",
"totalDuration": "00:00:00.7876907",
"entries": {
"google": {
"data": {},
"duration": "00:00:00.2020500",
"status": "Healthy"
},
"microsoft": {
"data": {},
"duration": "00:00:00.2967976",
"status": "Healthy"
},
"littleblocks": {
"data": {},
"duration": "00:00:00.2885959",
"status": "Healthy"
}
}
}