This libray has been discontinued in favor of BeatPulse
Health checking is the process where load balancers or application delivery controller does periodic check on our applications to make sure that they are up and responding without any problems. If our applications are down for every reason or any of the system that our applications depends on (A database, a distributed cache, web service, ect) are down, the load balancer should detect this and stop sending traffic its way.
AspNetCore.Health enables load balancers to monitor the status of deployed Web applications.
AspNetCore.Health enables you to do the following tasks:
- Monitor the performance of an AspNetCore application to make sure that it is healthy.
- Rapidly diagnose applications or systems that are failing.
You should install AspNetCore.Health with NuGet:
Install-Package AspNetCore.Health
This command from Package Manager Console will download and install AspNetCore.Health and all required dependencies.
By default AspNetCore provides out of the box some health checks providers:
- Check Urls (Http services)
- Ftp
public void ConfigureServices(IServiceCollection app)
{
services.AddHealthChecks(context =>
{
context
.AddUrlCheck("http://www.google.com")
.AddFtp("ftp.uconn.edu", "anonymous", "", 21, FtpTransferMode.Binary, "Public Ftp Test");
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseHealthCheck("/health")
}
You can create your own health check providers in a functional style avoiding inheritance:
Func<Task<HealthCheckResult>>
You can see some examples [here] (https://github.com/lurumad/aspnetcore-health/blob/master/src/AspNetCore.Health/HealthCheckContextExtensions.cs)
Run the HealthSample and open your browser http://localhost:5000/health
[
{
Name: "WebService (Google)",
Status: "Healthy"
}
]
If all services are healthy, returns http 200 OK status code, but if there are any unhealthy service returns http 500 Internal Server Error status code.
Try with other services!
Platform | Status |
---|---|
AppVeyor (.NET Core) |
Copyright © 2016 Luis Ruiz (lurumad)