Health check configuration for RepletoryLib
$ dotnet add package RepletoryLib.HealthChecksHealth check configuration for SQL Server, PostgreSQL, Redis, RabbitMQ, and external URIs.
Part of the RepletoryLib ecosystem -- standalone, reusable .NET 10 libraries with zero business logic.
RepletoryLib.HealthChecks provides a configuration-driven approach to health checks for ASP.NET Core applications. Enable checks for your infrastructure dependencies via appsettings.json and get a detailed JSON health report at /health.
dotnet add package RepletoryLib.HealthChecks
| Package | Type |
|---|---|
RepletoryLib.Common | RepletoryLib |
AspNetCore.HealthChecks.SqlServer | NuGet |
AspNetCore.HealthChecks.NpgSql | NuGet |
AspNetCore.HealthChecks.Redis | NuGet |
AspNetCore.HealthChecks.RabbitMQ | NuGet |
AspNetCore.HealthChecks.Uris | NuGet |
using RepletoryLib.HealthChecks;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRepletoryHealthChecks(builder.Configuration);
var app = builder.Build();
app.UseRepletoryHealthChecks();
{
"HealthChecks": {
"EnableSqlServer": true,
"SqlServerConnection": "Server=localhost,1433;Database=MyApp;User Id=sa;Password=Repletory@123!;TrustServerCertificate=true",
"EnablePostgres": true,
"PostgresConnection": "Host=localhost;Port=5432;Database=myapp;Username=repletory;Password=Repletory@123!",
"EnableRedis": true,
"RedisConnection": "localhost:6379",
"EnableRabbitMq": true,
"RabbitMqConnection": "amqp://repletory:Repletory@123!@localhost:5672",
"ExternalUrls": ["https://api.example.com/health"]
}
}
| Property | Type | Default | Description |
|---|---|---|---|
EnableSqlServer | bool | false | Enable SQL Server health check |
SqlServerConnection | string? | null | SQL Server connection string |
EnablePostgres | bool | false | Enable PostgreSQL health check |
PostgresConnection | string? | null | PostgreSQL connection string |
EnableRedis | bool | false | Enable Redis health check |
RedisConnection | string? | null | Redis connection string |
EnableRabbitMq | bool | false | Enable RabbitMQ health check |
RabbitMqConnection | string? | null | RabbitMQ AMQP connection string |
ExternalUrls | List<string> | [] | External URLs to check |
GET /health returns:
{
"status": "Healthy",
"totalDuration": "00:00:00.1234567",
"entries": {
"sqlserver": {
"status": "Healthy",
"duration": "00:00:00.0234567",
"description": null,
"tags": ["database", "sqlserver"]
},
"redis": {
"status": "Healthy",
"duration": "00:00:00.0012345",
"description": null,
"tags": ["cache", "redis"]
},
"rabbitmq": {
"status": "Degraded",
"duration": "00:00:05.0000000",
"description": "Connection timed out",
"tags": ["messaging", "rabbitmq"]
}
}
}
# docker-compose.yml
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
# Kubernetes
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 10
periodSeconds: 30
| Package | Relationship |
|---|---|
RepletoryLib.Common | Direct dependency |
RepletoryLib.Caching.Redis | Redis health check |
RepletoryLib.Messaging.RabbitMQ | RabbitMQ health check |
RepletoryLib.Data.EntityFramework | SQL Server / PostgreSQL health check |
RepletoryLib.Metrics | Health status can be exposed as Prometheus gauge |
This project is licensed under the MIT License.
Copyright (c) 2024-2026 Repletory.
For complete documentation, infrastructure setup, and configuration reference, see the RepletoryLib main repository.