Health Checks UI

The Health Checks UI component is being phased out of ROC. Our recommended path forward is to utilize an external appliance for monitoring ROC’s components (prometheus, zabbix, etc.)

Introduction

Health Checks UI (HCUI) is an elegant solution that helps developers and server teams track the health of their systems.

In this developer's guide, we will cover the HCUI settings and features. We will provide an overview of how the different components work and how you can extend them to suit your specific requirements.

Link to official documentation: https://learn.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/monitor-app-health

Health Checks UI Overview

Health Checks UI is a user-friendly web interface that displays the health status of your platform's various components. It shows a list of monitored endpoints, allowing you to easily spot issues and address them promptly. HCUI is built on top of the health check middleware, which is responsible for monitoring each component and reporting the results.

Accessing the Health Checks UI Dashboard

To access the Health Checks UI Dashboard, navigate to the /system/hc URL in your web browser. Please note that this URL is only accessible to admin users.

HCUI Features

HCUI offers several features that help you efficiently monitor ROC’s health:

  1. Dashboard: The dashboard provides a bird's-eye view of the overall health of your ROC services and projects.

  2. Details: You can click on any component to view more information, such as the duration of the last check and the next scheduled check.

  3. History: HCUI stores the health check history, allowing you to analyze trends and identify recurring issues.

  4. Notifications: You can configure HCUI to send notifications when the health status of a component changes. This can be done using Webhooks, or any custom notification system.

Extending Health Checks UI

You can extend the functionality of HCUI to suit your specific requirements:

  1. Custom Health Checks: You can create custom health checks by implementing the IHealthCheck interface and adding them to your health checks configuration.

  2. Custom Storage: By default, HCUI uses in-memory storage, but you can implement a custom storage provider.

Add additional health checks

You can add additional health checks to the health check builder in the Roc.HealthCheck -> HealthChecksExtension.cs -> AddRocHealthChecksUI() project, either implement a custom health check or use the available in the HCUI repository https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks#health-checks

When you add a new health check, you must assign it a tag. You should avoid using the system tag as it is reserved for internal ROC health checks and can prevent projects from being deployed correctly.

Configuration Overview

The roc.json file contains the HCUI configuration settings under the HealthChecksUI key. These settings control the behavior of the HCUI, such as enabling/disabling the interface, defining health checks, and configuring check intervals.

Here's an example of the HealthChecksUI configuration section:

{ "HealthChecksUI": { "Enabled": true, "RocHealthChecks": [ { "Name": "ROC Services Monitor", "Uri": "/hc-services", "Tag": "services" }, { "Name": "ROC Projects Monitor", "Uri": "/hc-projects", "Tag": "projects" } ], "EvaluationTimeOnSeconds": 10, "MinimumSecondsBetweenFailureNotifications": 60 } }

Configuration Properties

  • Enabled: Determines whether the Health Checks UI is enabled or not.

  • RocHealthChecks: An array of health check configurations, each containing:

    • Name: A unique identifier for the health check.

    • Uri: The relative URL of the endpoint to check (e.g., /hc-services).

    • Tag: A tag to group health checks for easier management and filtering. Avoid using the 'system' tag, as it is reserved for the '/healthz' endpoint.

  • EvaluationTimeOnSeconds: The interval (in seconds) at which health checks are performed.

  • MinimumSecondsBetweenFailureNotifications: The minimum interval (in seconds) between notifications when a health check fails. This prevents excessive notifications for the same failing health check.

Extending with New Endpoints

To add a new health check endpoint to the Roc app, follow these steps:

  1. Define the Health Check: Create a new health check class that implements the IHealthCheck interface, and register it in the AddRocHealthChecks method.

  2. Add Endpoint to the RocHealthChecks Array: In the appsettings.json file, add a new object to the RocHealthChecks array with the following properties:

    • Name: A unique identifier for the health check.

    • Uri: The relative URL of the endpoint to check (e.g., /hc-new-component).

    • Tag: A tag to group health checks for easier management and filtering.

Example:

jsonCopy code{ "Name": "ROC New Component Monitor", "Uri": "/hc-new-component", "Tag": "new-component" }

After adding the new health check configuration, the Health Checks UI will automatically start monitoring the new endpoint based on the specified interval (EvaluationTimeOnSeconds).