Totallytech.Healthcheck 1.0.0
Totallytech Health Check Configuration
This README provides instructions on configuring health checks in your ASP.NET Core application, including additional custom checks, based on the provided HealthChecksConfig.
HealthChecksConfig Structure
The HealthChecksConfig structure defines the health checks for your application. Each health check specifies the name, type, and URI of the endpoint to check.
"HealthChecksConfig": {
"HealthChecks": [
{
"Name": "companyApi",
"HealthCheckTypes": 2,
"Uri": "https://localhost:7011/health"
}
]
}
- Name: Descriptive name of the health check.
- HealthCheckTypes: Type of health check:
1: GRPC2: External API3: RabbitMQ4: Redis
- Uri: URI of the endpoint to check.
Integrating Health Checks
Configure Health Checks:
Add the
HealthChecksConfigsection to yourappsettings.jsonor other configuration source.Register Health Checks:
Add the following line to your
Startup.csto register health checks based on the configuration, including custom checks:builder.Services.AddCustomHealthChecks(builder.Configuration) .AddCheck("custom", () => { // Your custom health check logic if (success) return HealthCheckResult.Healthy("Your description"); else return HealthCheckResult.Unhealthy("Error description"); });Use Health Checks Middleware:
Enable the health checks endpoint by adding the following middleware in the
Configuremethod ofStartup.cs:app.UseCustomHealthChecks();
Additional Customization
Adding Extra Checks: Add more health checks by adding additional entries to the
HealthChecksarray inHealthChecksConfig.Custom Health Checks: Implement custom health checks using the
IHealthCheckinterface and register them in your application.
Monitoring
- Monitor the health of your application and its dependencies via the
/healthendpoint. This endpoint provides health status information.
Troubleshooting
- If health checks do not work as expected, refer to error messages, logs, and the provided troubleshooting steps to diagnose and resolve issues.
Conclusion
Integrating health checks ensures the reliability and availability of your ASP.NET Core application by monitoring its health and that of its dependencies. Follow the steps in this README to configure and use health checks effectively in your application.
No packages depend on Totallytech.Healthcheck.
.NET 8.0
- AspNetCore.HealthChecks.Rabbitmq (>= 8.0.1)
- AspNetCore.HealthChecks.UI.Client (>= 8.0.1)
- Grpc.AspNetCore.HealthChecks (>= 2.63.0)
- Grpc.HealthCheck (>= 2.63.0)
- Grpc.Net.Client (>= 2.63.0)
- Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore (>= 8.0.0)
- RabbitMQ.Client (>= 6.8.1)
- StackExchange.Redis (>= 2.6.122)