AspNetCore.Diagnostics.HealthChecks
AspNetCore.Diagnostics.HealthChecks copied to clipboard
Group by tags when set by appsettings
Hi,
I was wondering a way to group by tags in the UI using the appsettings.json like below.
"HealthChecksUI": {
"HealthChecks": [
{
"Name": "WebApp",
"Uri": "https://localhost:5001",
"Tags": "dev",
"Dependencies": [
{
"Name": "WebService1",
"Uri": "https://localhost:5002",
"Tags": "dev"
},
{
"Name": "WebService2",
"Uri": "https://localhost:5003",
"Tags": "dev"
}
]
}
]
}
The goal is to group by the tag name having the UI reflected as well.

Like this picture, but having a feature where it could be set everything through appsettings.json.
The AddUrlGroup kind "hardcodes" the dependencies, and ideally to have a dynamic/external configuration over appsettings, such parent-child (as dependencies).
Is something on the roadmap or workaround?
Thanks in advanced.
You can simply do it yourself. Just create new section in your appsettings:
"HealthChecks": {
"Services": [
{
"Name": "WebService1",
"Uri": "https://localhost:5002",
"Tag": "dev"
}
]
},
Map it to class:
var hcSection = Configuration.GetSection("HealthChecks:Services").Get<HealthCheckConfig[]>();
And use addUrlGroup:
var hc = services.AddHealthChecks()
.AddSqlServer(Configuration["Database:Connection"]);
var hcSection = Configuration.GetSection("HealthChecks:Services").Get<HealthCheckConfig[]>();
foreach (var service in hcSection)
{
hc.AddUrlGroup(new Uri(service.Uri), service.Name, HealthStatus.Unhealthy, new[] { service.Tag });
}