Quilt4Net.Toolkit.Health 0.6.0

dotnet add package Quilt4Net.Toolkit.Health --version 0.6.0
                    
NuGet\Install-Package Quilt4Net.Toolkit.Health -Version 0.6.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Quilt4Net.Toolkit.Health" Version="0.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Quilt4Net.Toolkit.Health" Version="0.6.0" />
                    
Directory.Packages.props
<PackageReference Include="Quilt4Net.Toolkit.Health" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Quilt4Net.Toolkit.Health --version 0.6.0
                    
#r "nuget: Quilt4Net.Toolkit.Health, 0.6.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Quilt4Net.Toolkit.Health@0.6.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Quilt4Net.Toolkit.Health&version=0.6.0
                    
Install as a Cake Addin
#tool nuget:?package=Quilt4Net.Toolkit.Health&version=0.6.0
                    
Install as a Cake Tool

Quilt4Net.Toolkit.Health

GitHub repo

Add configurable health endpoints, heartbeat telemetry, and service monitoring to .NET Web Applications.

Get started

Install the NuGet package Quilt4Net.Toolkit.Health and register the services in Program.cs.

var builder = WebApplication.CreateBuilder(args);

builder.AddQuilt4NetHealth();

var app = builder.Build();

app.UseRouting();
app.UseQuilt4NetHealth();

app.Run();

UseRouting() must be called before UseQuilt4NetHealth().

Endpoints

Six endpoints are available by default. The base path is ~/api/Health (configurable via Pattern and ControllerName).

Endpoint Path Purpose
Live /api/Health/live Returns Alive if the process is running. Use for container orchestration (Kubernetes, Azure).
Ready /api/Health/ready Checks essential components. Returns Ready, Degraded, or Unready (503).
Health /api/Health/health Full system check including all components and dependencies. Returns Healthy, Degraded, or Unhealthy (503).
Dependencies /api/Health/dependencies Checks external dependencies one level deep (no circular checks).
Metrics /api/Health/metrics Returns system metrics: CPU, memory, storage, GPU, and uptime. GET only.
Version /api/Health/version Returns application metadata: version, environment, IP address, machine name. GET only.

All endpoints support both GET (returns JSON body) and HEAD (returns status in header), except Metrics and Version which are GET only.

Components

Components are services or resources that your application depends on. Add them to include in Health and Ready checks.

Inline check

builder.AddQuilt4NetHealth(o =>
{
    o.AddComponent(new Component
    {
        Name = "database",
        Essential = true,
        CheckAsync = async sp =>
        {
            // perform check
            return new CheckResult { Success = true, Message = "Connected" };
        }
    });
});

Set Essential = true for critical components (failure = Unhealthy/Unready). Set Essential = false for non-critical components (failure = Degraded).

Component service

For complex checks, implement IComponentService to separate setup from logic.

builder.AddQuilt4NetHealth(o =>
{
    o.AddComponentService<MyComponentService>();
});

Dependencies

Register external services that use Quilt4Net Health API. The dependency endpoint calls their health check.

builder.AddQuilt4NetHealth(o =>
{
    o.AddDependency(new Dependency
    {
        Name = "payment-service",
        Essential = true,
        Uri = new Uri("https://payment.example.com/api/Health/")
    });
});

Heartbeat

The heartbeat feature sends periodic availability telemetry to Application Insights.

Enable heartbeat

builder.AddQuilt4NetHealth(o =>
{
    o.Heartbeat.Enabled = true;
    o.Heartbeat.Interval = TimeSpan.FromMinutes(5);
});

The heartbeat starts when UseQuilt4NetHealth() is called.

TelemetryClient resolution

The heartbeat resolves a TelemetryClient in this order:

  1. From DI - If AddApplicationInsightsTelemetry() has been called, that client is used.
  2. From HeartbeatOptions - If Heartbeat.ConnectionString is set, a client is created from it.
  3. None - A warning is logged and heartbeat execution is skipped.
builder.AddQuilt4NetHealth(o =>
{
    o.Heartbeat.Enabled = true;
    o.Heartbeat.ConnectionString = builder.Configuration["ApplicationInsights:ConnectionString"];
});

HeartbeatOptions

Property Default Description
Enabled false Enable/disable the heartbeat background service.
Interval 5 minutes Time between heartbeat executions.
ConnectionString null Application Insights connection string. Used only if no TelemetryClient is registered via DI.

Service probe

Monitor the health of background services and hosted services through a pulse mechanism.

Inject IHostedServiceProbe<T> into your hosted service and call Pulse() on each iteration.

public class MyBackgroundService : BackgroundService
{
    private readonly IHostedServiceProbe _probe;

    public MyBackgroundService(IHostedServiceProbe<MyBackgroundService> probe)
    {
        _probe = probe.Register(plannedInterval: TimeSpan.FromSeconds(30));
    }

    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
        while (!stoppingToken.IsCancellationRequested)
        {
            _probe.Pulse();

            // do work...

            await Task.Delay(TimeSpan.FromSeconds(30), stoppingToken);
        }
    }
}

The probe tracks pulse timing and reports status in Health responses:

  • Healthy - Pulse received within the expected interval.
  • Degraded - Pulse slightly delayed.
  • Unhealthy - Pulse significantly delayed or missing.

Certificate check

Automatically checks SSL certificate expiry for your service and its dependencies.

Property Default Description
Certificate.SelfCheckEnabled true Check your own certificate.
Certificate.DependencyCheckEnabled true Check dependency certificates.
Certificate.SelfCheckUri null Explicit URI for self-check. Uses request host if not set.
Certificate.CertExpiryDegradedLimitDays 30 Days remaining before reporting Degraded.
Certificate.CertExpiryUnhealthyLimitDays 3 Days remaining before reporting Unhealthy.

Configuration

All options can be set via code, appsettings.json, or a combination of both. Priority order:

  1. Code - Highest priority, overrides everything.
  2. appsettings.json - Overrides defaults.
  3. Defaults - Used when nothing else is configured.

Code configuration

builder.AddQuilt4NetHealth(o =>
{
    o.Pattern = "api";
    o.ControllerName = "Health";
    o.FailReadyWhenDegraded = true;
    o.Heartbeat.Enabled = true;
});

appsettings.json

{
  "Quilt4Net": {
    "HealthApi": {
      "Pattern": "api",
      "ControllerName": "Health",
      "FailReadyWhenDegraded": true,
      "Heartbeat": {
        "Enabled": true,
        "Interval": "00:05:00",
        "ConnectionString": "InstrumentationKey=..."
      },
      "Certificate": {
        "CertExpiryDegradedLimitDays": 30,
        "CertExpiryUnhealthyLimitDays": 3
      }
    }
  }
}

Quilt4NetHealthApiOptions

Property Default Description
Pattern "api" URL segment between base address and controller name.
ControllerName "Health" Controller name in the URL path.
DefaultAction "Health" Default endpoint when no action is specified.
FailReadyWhenDegraded false Return 503 from Ready when the system is degraded.
OverrideState null Override state (Visible, Hidden, Disabled) for all endpoints.
AuthScheme "ApiKeyScheme" Authentication scheme used for endpoint access.
ExceptionDetail Environment-based Level of exception detail: Hidden, Message, or StackTrace.
IpAddressCheckUri http://ipv4.icanhazip.com/ URI for IP address lookup. Set to null to disable.

Endpoint access

Each endpoint has configurable access control and visibility.

builder.AddQuilt4NetHealth(o =>
{
    o.Endpoints[HealthEndpoint.Metrics].Get.Access.Level = AccessLevel.AuthenticatedOnly;
    o.Endpoints[HealthEndpoint.Health].Get.State = EndpointState.Hidden;
});

EndpointState: Visible (shown in docs), Hidden (accessible but not in docs), Disabled (not accessible).

AccessLevel: Everyone, AuthenticatedOnly.

DetailsLevel: Everyone, AuthenticatedOnly, NoOne - controls response detail in GET requests.

Environment defaults

Setting Development Production Other
Endpoint state Visible Hidden Visible
Access level Everyone AuthenticatedOnly Everyone
Details level Everyone AuthenticatedOnly AuthenticatedOnly
Exception detail StackTrace Hidden Message

Troubleshooting

Startup error: EndpointRoutingMiddleware matches endpoints setup by EndpointMiddleware...

Add app.UseRouting() before app.UseQuilt4NetHealth() in Program.cs.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.6.0 59 2/18/2026
0.5.4 193 2/7/2026
0.5.2 116 1/31/2026
0.4.7 127 1/8/2026
0.4.4 102 1/6/2026
0.4.2 105 1/6/2026