This is a small WebAPI application to try out the health checks feature.
Separate branch with the .NET Core 2.2 version.
Resources:
- Health checks in ASP.NET 📚 - Lots of examples
- The best way to add Health checks 📽️12min - Nick Chapsas
- Health checks for monitoring your applications 📓Milan
- Collection of packages 👤 - A list of packages and lots of information, HealthCheckUI
- Prepare you application to be monitored by Kubernetes 📓DEV.to / Ghassan Karwchan
public void ConfigureServices(IServiceCollection services)
{
...
// Install-Package Npgsql.EntityFrameworkCore.PostgreSQL
services.AddDbContext<DataBaseContext>(options
=> options.UseNpgsql(Configuration.GetConnectionString("PostgreSQL")));
...
// Add: Health checks.
services
.AddHealthChecks()
// Install-Package Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore
.AddDbContextCheck<DataBaseContext>()
// Install-Package AspNetCore.HealthChecks.Redis
.AddRedis(Configuration.GetConnectionString("Redis"))
// Install-Package AspNetCore.HealthChecks.MySql
.AddMySql(Configuration.GetConnectionString("MySQL"))
.AddCheck<RandomHealthCheck>("random");
// Install-Package AspNetCore.HealthChecks.UI
services.AddHealthChecksUI(); // Optional to use
}
- Redis: Description in my PlayingWithDistributedLock repository.
- MySql: Wiki page.
- Github: garethflowers / postgresql-portable / releases (database, user, password: postgres)