Configuration: Diagnostics Module ‐ Health Checks - ChrisMavrommatis/Binacle.Net GitHub Wiki

Health checks are crucial for ensuring the reliability and availability of your application. In Binacle.Net, they provide a robust mechanism for monitoring the application's status and integrating with external monitoring tools. These checks can trigger alerts and route traffic through load balancers, ensuring that requests are directed only to healthy instances of the application.

Configuration

The health check functionality can be configured via the HealthChecks.json file. Below is an example configuration:

{
  "HealthChecks": {
    "Enabled": false,
    "Path": "/_health",
    "RestrictedIPs": [],
    "RestrictedChecks": []
  }
}

Configuration Options

  • Enabled: A boolean flag to enable or disable health checks.
  • Path: The endpoint path that health checks will respond to (default is /_health).
  • RestrictedIPs: An array of IP addresses that are allowed to perform health checks. This can include:
    • Single IP addresses
    • Ranges of IP addresses
    • CIDR notation for specifying subnets
  • RestrictedChecks: An array that defines specific health checks to be excluded from execution. This may be necessary if you cannot apply IP restrictions to the health check endpoint, and you want to maintain the confidentiality of your internal setup.

Built-in Checks

  • Database: This check, typically available with the Service Module, queries the configured database to assess its health.

Example of Restricted IPs

You can configure the RestrictedIPs field with specific IP addresses or ranges. Here are a few examples:

"RestrictedIPs": [
  "192.168.1.1",                // Single IP
  "192.168.1.0-192.168.1.255",  // IP Range
  "192.168.1.0/24",             // IP Range using CIDR notation 
  "10.0.0.0/8"                  // Another CIDR range
]

This flexibility allows you to control which systems can perform health checks, enhancing the security of your application.

Example of Restricted Checks

You can configure the RestrictedChecks field to prevent specific checks from being executed. For example:

"RestrictedChecks": [
  "Database"
]

Integrating with Monitoring Tools

Once health checks are configured and enabled, they can be easily integrated with monitoring tools such as Prometheus, Grafana, or custom alerting systems. This integration can help you monitor the performance and availability of your application in real-time.

Conclusion

Health checks are an integral part of maintaining the health of your Binacle.Net application. Proper configuration and integration with monitoring tools ensure high availability and responsiveness, ultimately enhancing the user experience.

For further details or advanced configurations, please refer to the related sections in the Diagnostics Module documentation.