Substantive.AspNetCore.HealthChecks 9.17.7-build20260115r1

Substantive.AspNetCore.HealthChecks

Opinionated health-check host helpers for .NET services. The library delivers ready-to-use registration, response formatting, and endpoint helpers so every API in the estate exposes consistent readiness and liveness probes.

Highlights

  • Pre-registers liveness, CPU, and memory checks using AddHealthChecksHost.
  • Optional drive storage and Entity Framework DbContext checks that light up through configuration.
  • JSON response writer (HealthReportResponseWriter) that returns detailed status for dashboards and probes.
  • MapHealthCheckEndpoints helper that exposes health/readyz and health/livez endpoints with consistent tagging.

Getting Started

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddHealthChecksHost(options =>
{
    options.EnableDriveHealthCheck = builder.Environment.IsDevelopment();
    options.EnableDbContextHealthCheck = true;
    options.CPUUtilizationUnhealthyThreshold = 90;
});

var app = builder.Build();
app.MapHealthCheckEndpoints();
app.Run();

Service Registration

Call services.AddHealthChecksHost() in Program.cs (after other dependencies). The extension:

  1. Creates and validates HealthChecksHostOptions at startup.
  2. Registers resource monitoring (IResourceMonitor) required by CPU/memory checks.
  3. Adds health checks:
    • LivenessHealthCheck tagged with liveness.
    • CpuHealthCheck and MemoryHealthCheck tagged with readiness.
    • Optional drive storage checks per mounted drive when EnableDriveHealthCheck is true.
    • Optional AddDbContextCheck<TContext> for every registered DbContext when EnableDbContextHealthCheck is true.

Options Reference

Option Description Default
EnableDriveHealthCheck Adds disk checks for each drive. Avoid when running inside container images. false
EnableDbContextHealthCheck Adds EF DbContext connectivity checks. false
CPUUtilizationDegradedThreshold Percentage that triggers degraded result. 80
CPUUtilizationUnhealthyThreshold Percentage that triggers unhealthy result. Must be ≥ degraded threshold. 90
MemoryDegradedThreshold Memory usage percentage for degraded status. 90
MemoryUnhealthyThreshold Memory usage percentage for unhealthy status. Must be ≥ degraded threshold. 95
MinimumDiskRemainingThresholdMB Minimum free space (MB) per drive when drive checks are enabled. 500

All thresholds are validated through HealthChecksHostOptionsValidator and IOptionsValidateOnStart, so misconfigurations fail fast during app startup.

Endpoint Mapping

WebApplicationExtensions.MapHealthCheckEndpoints() maps two endpoints:

  • health/readyz → filters checks tagged with readiness or ready.
  • health/livez → filters checks tagged with liveness or live.

Both endpoints:

  • Use HealthReportResponseWriter to emit camel-cased JSON with enum values serialized as strings.
  • Allow response caching by default.
  • Can be wrapped in route groups or authorization middleware if needed.

Response Format

HealthReportResponseWriter.WriteDetailResponse serializes the full HealthReport, including individual entry status, description, data, and duration. The writer honors HttpContext.RequestAborted and sets application/json; charset=utf-8.

Customization Tips

  • Override thresholds per environment using app configuration (e.g., appsettings.Production.json).
  • Add custom health checks by chaining services.AddHealthChecks() after calling AddHealthChecksHost().
  • For multi-tenant or multi-region deployments, prepend a path segment or require host filtering by wrapping MapHealthCheckEndpoints() with additional middleware.

Showing the top 20 packages that depend on Substantive.AspNetCore.HealthChecks.

Packages Downloads
Substantive.AspNetCore
Substantive ASP.NET Core package.
4
Substantive.AspNetCore
Substantive ASP.NET Core package.
5
Substantive.AspNetCore
Substantive ASP.NET Core package.
6
Substantive.AspNetCore
Substantive ASP.NET Core package.
8
Substantive.AspNetCore
Substantive ASP.NET Core package.
19
Substantive.AspNetCore
Substantive ASP.NET Core package.
21
Substantive.AspNetCore
Substantive ASP.NET Core package.
22
Substantive.AspNetCore
Substantive ASP.NET Core package.
23
Substantive.AspNetCore
Substantive ASP.NET Core package.
24
Substantive.Metapackage.AspNetCoreServer
A metapackage contains all Substantive ASP.NET Core server-side packages.
3
Substantive.Metapackage.Backends
A metapackage contains all Substantive backend building blocks.
3

Version Downloads Last updated
9.17.21-build20260204R1 0 02/04/2026
9.17.20-build20260203R1 2 02/03/2026
9.17.19-build20260130R1 8 01/30/2026
9.17.18-build20260129R1 19 01/29/2026
9.17.17-build20260129R1 23 01/29/2026
9.17.17-build20260128R1 21 01/28/2026
9.17.16-build20260127R2 22 01/27/2026
9.17.16-build20260123R1 4 01/23/2026
9.17.15-build20260122R1 6 01/22/2026
9.17.14-build20260122R2 6 01/22/2026
9.17.14-build20260122R1 2 01/22/2026
9.17.14-build20260121R1 2 01/21/2026
9.17.13-build20260121R1 2 01/21/2026
9.17.12-build20260120R1 6 01/20/2026
9.17.11-build20260120R1 5 01/20/2026
9.17.10-build20260120R1 4 01/20/2026
9.17.9-build20260119R1 5 01/19/2026
9.17.8-build20260119R1 4 01/19/2026
9.17.7-build20260115R1 2 01/15/2026
9.17.6-build20260115R1 1 01/15/2026
9.17.5-build20260119R1 4 01/19/2026
9.17.5-build20260115R1 2 01/15/2026
9.17.4-build20260115R1 4 01/15/2026
9.17.3-build20260115R1 1 01/15/2026
9.17.2-build20260115R1 1 01/15/2026
9.17.2-build20260113R1 24 01/13/2026