Documentation

Health Checks Endpoints

Health checks enable services to report their operational status to external systems like load balancers and monitors. Through endpoints such as liveness, readiness, and startup checks, applications can signal their ability to process requests. This proactive monitoring detects failures early, minimizes downtime, optimizes resources, and enhances system resilience—especially critical in distributed systems and microservices.

Nomirun Host comes with 3 health check endpoints for validating different states.

1. Startup endpoint

This health check endpoint is built-in the Nomirun host, and it’s located at /startup endpoint.

If a Nomirun Host has successfully started and loaded the startup health check code then the /startup endpoint will return 200 HTTP status code.

2. Liveness endpoint

This health check endpoint is built-in the Nomirun host, and it’s located at /liveness endpoint.

Liveness endpoint is hooking into IHostApplicationLifetime instance and validates if the Nomirun Host application is running or not. In case it’s running the /liveness endpoint will return 200 HTTP status code.

3. Readiness endpoint

It is located at /readiness endpoint of the Nomirun Host. It is the health check that checks all registered infrastructure dependencies (like cloud services, SQL servers, WEB servers, …) that are configured with Readiness tag.

Nomirun Host comes with /status endpoint as well, where you can see details of Readiness health checks:

{
  "app": "Nomirun",
  "version": "1.1.2.0",
  "status": "Healthy",
  "results": {
    "Service Startup": {
      "status": "Healthy",
      "time": "0,9682 ms"
    },
    "Self Test": {
      "status": "Healthy",
      "time": "0,524 ms"
    }
  }
}

Nomirun Host by default does not contain any infrastructure Readiness health checks, but it is something you can add to your module. Below is an example for Postgresql database health check:

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;

namespace MyModule.HealthChecks;

public static class HealthCheckExtensions
{
    public static void AddPostgreSqlHealthChecks(this IServiceCollection services,
        string connectionString, string databaseName)
    {
        services.AddHealthChecks()
            .AddNpgSql(connectionString,
                "SELECT 1;",
                null,
                $"PostgreSQL Server - {databaseName}",
                HealthStatus.Unhealthy,
                new[] { "postgresql", HealthCheckProbeType.Readiness },
                TimeSpan.FromSeconds(5));
    }
}

Make sure you add 2 Nuget packages:

<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="9.0.0" />
<PackageReference Include="Npgsql" Version="9.0.3" />

And then register it in the Startup.cs:

services.AddPostgreSqlHealthChecks("<connectionstring>", "Demo");

When you run the module and go to /status endpoint, you will see something like this:

{
  "app": "Nomirun",
  "version": "1.1.2.0",
  "status": "Healthy",
  "results": {
    "PostgreSQL Server - Demo": {
      "status": "Healthy",
      "time": "2,4702 ms"
    },
    "Service Startup": {
      "status": "Healthy",
      "time": "0,9682 ms"
    },
    "Self Test": {
      "status": "Healthy",
      "time": "0,524 ms"
    }
  }
}