Totallytech.Healthcheck 1.0.2.1

Totalytech Health Check Configuration README

This README provides instructions on configuring health checks in your ASP.NET Core application, including additional custom checks for both GRPC and web API services.

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": "your api name",
      "HealthCheckTypes": 2,
      "Uri": "your api endpoint"
    }
  ]
}
  • 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:

    Depending on your service type, use one of the following methods to register health checks:

    • If your service is a GRPC service, use:

      builder.Services.AddCustomGrpcHealthChecks(builder.Configuration)
                      .AddCheck("custom", () =>
                      {
                          // Your custom health check logic
                          if (success)
                              return HealthCheckResult.Healthy("Your description");
                          else
                              return HealthCheckResult.Unhealthy("Error description");
                      });
      
    • If your service is a web API, use:

      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:

    Depending on your service type, use one of the following methods to use health checks middleware:

    • If your service is a web API, use:

      app.UseCustomHealthChecks();
      
    • If your service is a GRPC service, use:

      app.MapGrpcHealthChecks();
      

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