AspNetCore.Diagnostics.HealthChecks
AspNetCore.Diagnostics.HealthChecks copied to clipboard
When use method SetNotifyUnHealthyOneTimeUntilChange stop polling API's endpoints health checks
Please, fill the following sections to help us fix the issue
What happened: By implementing the SetNotifyUnHealthyOneTimeUntilChange method in the configuration to avoid spam notifications through a webhook, the polling of the configured APIs, which is 10 seconds, stops and does not poll any API again. And when I remove the SetNotifyUnHealthyOneTimeUntilChange configuration the API's polling works correctly.
What you expected to happen: That when implementing the SetNotifyUnHealthyOneTimeUntilChange method, the polling of the configured APIs will continue to execute normally
How to reproduce it (as minimally and precisely as possible): I simply added the SetNotifyUnHealthyOneTimeUntilChange method in the AddHealthChecksUI configuration and the API's polling stopped.
Source code sample:
builder.Services.AddHealthChecksUI(setup =>
{
setup.SetNotifyUnHealthyOneTimeUntilChange(); //Add this line generated the issue
SetupHealthEndpoints(setup); //Own method, below is the definition
SetupWebhooks(setup); //Own method, below is the definition
setup.SetHeaderText("Superapp Health Check DashBoard");
setup.SetEvaluationTimeInSeconds(int.Parse(Environment.GetEnvironmentVariable("EVALUATIONTIME") ?? "10"));
setup.SetMinimumSecondsBetweenFailureNotifications(int.Parse(Environment.GetEnvironmentVariable("FAILURENOTIFICATIONSTIME") ?? "60"));
setup.MaximumHistoryEntriesPerEndpoint(int.Parse(Environment.GetEnvironmentVariable("MAXIMUMHISTORYENTRIES") ?? "60"));
}).AddSqlServerStorage(Environment.GetEnvironmentVariable("DATABASE_CONNECTION")?? "");
static void SetupHealthEndpoints(Settings setup)
{
var healthEndpoints = JsonConvert.DeserializeObject<List<HealthEndpointDto>>(Environment.GetEnvironmentVariable("HEALTHCHECK_ENDPOINTS")??"") ?? new List<HealthEndpointDto>();
if (healthEndpoints.Any())
{
foreach (var healthEndpointDto in healthEndpoints)
{
setup.AddHealthCheckEndpoint(healthEndpointDto.Name, healthEndpointDto.Url.ToString());
}
}
}
static void SetupWebhooks(Settings setup)
{
var webhooks = JsonConvert.DeserializeObject<List<WebHookDto>>(Environment.GetEnvironmentVariable("WEBHOOKS") ?? "") ?? new List<WebHookDto>();
if (webhooks.Any())
{
foreach (var webhook in webhooks)
{
setup.AddWebhookNotification(webhook.Name, webhook.Url.ToString(), webhook.Payload, restorePayload: webhook.RestorePayload);
}
}
}
Anything else we need to know?:
Environment:
- .NET Core version: NetCore6
- Healthchecks version: AspNetCore.HealthChecks.UI (7.0.2), AspNetCore.HealthChecks.UI.Client (7.1.0), AspNetCore.HealthChecks.UI.InMemory.Storage (7.0.0), AspNetCore.HealthChecks.UI.SqlServerStorage (7.0.0)
- Operative system: Windows
- Others:
I observe the same behavior on .net7