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: GRPC
    • 2: External API
    • 3: RabbitMQ
    • 4: Redis
  • Uri: URI of the endpoint to check.

Integrating Health Checks

  1. Configure Health Checks:

    Add the HealthChecksConfig section to your appsettings.json or other configuration source.

  2. Register Health Checks:

    Add the following line to your Startup.cs to 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");
                     });
    
  3. Use Health Checks Middleware:

    Enable the health checks endpoint by adding the following middleware in the Configure method of Startup.cs:

    app.UseCustomHealthChecks();
    

Additional Customization

  • Adding Extra Checks: Add more health checks by adding additional entries to the HealthChecks array in HealthChecksConfig.

  • Custom Health Checks: Implement custom health checks using the IHealthCheck interface and register them in your application.

Monitoring

  • Monitor the health of your application and its dependencies via the /health endpoint. 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.

Version Downloads Last updated
1.0.2.2 111 6/15/2024
1.0.2.1 10 6/15/2024
1.0.2 120 6/10/2024
1.0.1 111 6/9/2024
1.0.0 10 6/9/2024