Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HealthCheck add possibility to cache checks and protect API from DDOS attacks #59561

Open
1 task done
Ben555555 opened this issue Dec 19, 2024 · 0 comments
Open
1 task done
Labels
area-healthchecks Includes: Healthchecks (some bugs also in Extensions repo)

Comments

@Ben555555
Copy link

Ben555555 commented Dec 19, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Currently there is no way to run health checks like DbContextCheck periodically. Therefor the Health check endpoints can be abused to be very exhaustive for the API.

Describe the solution you'd like

There are already HealthCheckPublishers but currently even when they are applied the checks are made on each request. It would be nice if there was an option to use this also for returning the last published check results. It would be even better to be able to cache the results without an additional publisher by just using an additional setting or allowing to hook into the process to add a cache.

Additional context

public class PeriodHealthCheckPublisher : IHealthCheckPublisher
{
    public Task PublishAsync(HealthReport report, CancellationToken cancellationToken)
    {
        return Task.CompletedTask;
    }
}

services.Configure<HealthCheckPublisherOptions>(options =>
{
    options.Delay = TimeSpan.FromSeconds(2); // Initial delay
    options.Period = TimeSpan.FromSeconds(60); // delay between checks
    options.Predicate = _ => true;
});

services.AddSingleton<IHealthCheckPublisher, PeriodHealthCheckPublisher>();

services.AddHealthChecks();

Currently whenever the healthcheck endpoint is called all the checks are executed again.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-healthchecks Includes: Healthchecks (some bugs also in Extensions repo) label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-healthchecks Includes: Healthchecks (some bugs also in Extensions repo)
Projects
None yet
Development

No branches or pull requests

1 participant