A simple .NET client for your health endpoint
A lightweight .NET library that provides a standardized schema for exposing service health information. Use this library to make your services compatible with the Simple Observability monitoring dashboard.
Key Features:
- 📊 Standard health metadata schema
- 🚀 Zero-configuration setup
- 🎯 Simple POCO classes
- ✅ Compatible with ASP.NET Core Minimal APIs and MVC
- 🔍 Optional additional metadata support
dotnet add package WorldDomination.SimpleObservabilityAdd a /healthz endpoint to your ASP.NET Core application:
usingWorldDomination.SimpleObservability;varbuilder=WebApplication.CreateBuilder(args);varapp=builder.Build();app.MapGet("/healthz",()=>{varhealth=newHealthMetadata{ServiceName="My API Service",Version="1.0.0",Environment="Production",Status=HealthStatus.Healthy};returnResults.Json(health);});app.Run();app.MapGet("/healthz",()=>{varhealth=newHealthMetadata{ServiceName="My API Service",Version="1.2.3",Environment="Production",Status=HealthStatus.Healthy,Timestamp=DateTimeOffset.UtcNow,HostName=Environment.MachineName,Uptime=TimeSpan.FromHours(24),Description="All systems operational",AdditionalMetadata=newDictionary<string,string>{["Database"]="Connected",["Cache"]="Redis v7.0",["Region"]="us-west-2"}};returnResults.Json(health);});HealthStatus.Healthy- Service is operating normally.HealthStatus.Degraded- Service is operational but experiencing issues.HealthStatus.Unhealthy- Service is not operating correctly.
{
"serviceName": "My API Service",
"version": "1.2.3",
"environment": "Production",
"status": "Healthy",
"timestamp": "2024-01-15T10:30:00Z",
"hostName": "server-01",
"uptime": "1.00:00:00",
"description": "All systems operational",
"additionalMetadata": {
"database": "Connected",
"cache": "Redis v7.0",
"region": "us-west-2"
}
}Contributions are welcome! Please feel free to submit a Pull Request.
See LICENSE for details.