NetEvolve.HealthPublishers.Prometheus.PushGateway
1.10.0
Prefix Reserved
dotnet add package NetEvolve.HealthPublishers.Prometheus.PushGateway --version 1.10.0
NuGet\Install-Package NetEvolve.HealthPublishers.Prometheus.PushGateway -Version 1.10.0
<PackageReference Include="NetEvolve.HealthPublishers.Prometheus.PushGateway" Version="1.10.0" />
<PackageVersion Include="NetEvolve.HealthPublishers.Prometheus.PushGateway" Version="1.10.0" />
<PackageReference Include="NetEvolve.HealthPublishers.Prometheus.PushGateway" />
paket add NetEvolve.HealthPublishers.Prometheus.PushGateway --version 1.10.0
#r "nuget: NetEvolve.HealthPublishers.Prometheus.PushGateway, 1.10.0"
#:package NetEvolve.HealthPublishers.Prometheus.PushGateway@1.10.0
#addin nuget:?package=NetEvolve.HealthPublishers.Prometheus.PushGateway&version=1.10.0
#tool nuget:?package=NetEvolve.HealthPublishers.Prometheus.PushGateway&version=1.10.0
NetEvolve.HealthPublishers.Prometheus.PushGateway
An IHealthCheckPublisher implementation that pushes HealthReport results to a Prometheus Pushgateway instance, using the text exposition format directly over HTTP (PUT /metrics/job/<job>/instance/<instance>). PUT fully replaces the metric group on every publish, so checks that are removed or renamed don't leave stale series behind.
Features
- Pushes a full set of gauge metrics per publish: overall report status, report duration, last publish timestamp, and per-check status and duration
- Maps
HealthStatusto a numeric gauge value using the enum's own ordinal (Unhealthy→0,Degraded→1,Healthy→2) - Labels every metric with the machine name and a required, free-form
SystemIdentifierto tell instances apart - Requires a distinct
Instanceper publisher so Pushgateway groups each publisher's metrics under its own path, instead of publishers sharing aJoboverwriting each other's same-named metrics JobandInstancevalues containing a/are sent using Pushgateway's@base64grouping-key syntax, since percent-encoding a slash does not stop Pushgateway from treating it as a path separator- Configuration- or builder-based setup, consistent with the
NetEvolve.HealthChecks.*conventions - Named registrations to publish to multiple Pushgateway targets side by side
- No
prometheus-netclient dependency - justHttpClientviaIHttpClientFactory
Installation
NuGet Package Manager
Install-Package NetEvolve.HealthPublishers.Prometheus.PushGateway
.NET CLI
dotnet add package NetEvolve.HealthPublishers.Prometheus.PushGateway
PackageReference
<PackageReference Include="NetEvolve.HealthPublishers.Prometheus.PushGateway" Version="x.x.x" />
Quick Start
using NetEvolve.HealthPublishers.Prometheus.PushGateway;
var builder = services.AddHealthChecks();
builder.AddPrometheusPushGateway(options =>
{
options.ServerUrl = new Uri("https://pushgateway.example.com");
options.Job = "checkout-service";
options.Instance = "checkout-service-01";
options.SystemIdentifier = "checkout-service";
});
Usage
Basic Example
Register under the default name ("Default"), configured via code:
var builder = services.AddHealthChecks();
builder.AddPrometheusPushGateway(options =>
{
options.ServerUrl = new Uri("https://pushgateway.example.com"); // Required
options.Job = "checkout-service"; // Required, used as the `job` path segment
options.Instance = "checkout-service-01"; // Required, used as the `instance` path segment
options.SystemIdentifier = "checkout-service"; // Required, labels every metric alongside the machine name
});
Advanced Example
Register multiple named Pushgateway targets, each pushing the same health reports to a different instance:
var builder = services.AddHealthChecks();
builder.AddPrometheusPushGateway("Internal", options =>
{
options.ServerUrl = new Uri("https://pushgateway-internal.example.com");
options.Job = "checkout-service";
options.Instance = "checkout-service-01";
options.SystemIdentifier = "checkout-service";
});
builder.AddPrometheusPushGateway("External", options =>
{
options.ServerUrl = new Uri("https://pushgateway-external.example.com");
options.Job = "checkout-service";
options.Instance = "checkout-service-01";
options.SystemIdentifier = "checkout-service";
});
Configuration
Code-based
builder.AddPrometheusPushGateway(options =>
{
options.ServerUrl = new Uri("https://pushgateway.example.com"); // Required
options.Job = "checkout-service"; // Required
options.Instance = "checkout-service-01"; // Required
options.SystemIdentifier = "checkout-service"; // Required
});
appsettings.json-based
builder.AddPrometheusPushGateway(); // reads the "Default" section below
{
"HealthPublishers": {
"Prometheus": {
"PushGateway": {
"Default": {
"ServerUrl": "https://pushgateway.example.com",
"Job": "checkout-service",
"Instance": "checkout-service-01",
"SystemIdentifier": "checkout-service"
}
}
}
}
}
When using an explicit name, the section key must match: builder.AddPrometheusPushGateway("External") reads HealthPublishers:Prometheus:PushGateway:External.
Published Metrics
| Metric | Type | Labels | Description |
|---|---|---|---|
healthcheck_report_status |
gauge | system_identifier, machine_name |
Overall health report status (0/1/2) |
healthcheck_report_duration_seconds |
gauge | system_identifier, machine_name |
Total duration of the health report execution |
healthcheck_last_publish_timestamp_seconds |
gauge | system_identifier, machine_name |
Unix timestamp of the last publish attempt |
healthcheck_status |
gauge | check, description, system_identifier, machine_name |
Status of an individual health check entry (0/1/2) |
healthcheck_duration_seconds |
gauge | check, description, system_identifier, machine_name |
Duration of an individual health check entry |
The job and instance labels are not part of the exposition body - the Pushgateway derives them from the request path (options.Job and options.Instance) and applies them automatically.
Requirements
- .NET 8.0 or higher
- A running Prometheus Pushgateway instance
Related Packages
- NetEvolve.HealthPublishers.Abstractions - Shared abstractions used by all
NetEvolve.HealthPublishers.*packages
Documentation
For complete documentation, please visit the official documentation.
Contributing
Contributions are welcome! Please read the Contributing Guidelines before submitting a pull request.
Support
- Issues: Report bugs or request features on GitHub Issues
- Documentation: Read the full documentation at https://github.com/dailydevops/healthpublishers
License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by the NetEvolve Team Visit us at https://www.daily-devops.net for more information about our services and solutions.
| Product | Versions 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. |
-
net10.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.10)
- Microsoft.Extensions.Http (>= 10.0.10)
- Microsoft.Extensions.Options (>= 10.0.10)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.10)
-
net8.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.10)
- Microsoft.Extensions.Http (>= 10.0.10)
- Microsoft.Extensions.Options (>= 10.0.10)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.10)
-
net9.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.10)
- Microsoft.Extensions.Http (>= 10.0.10)
- Microsoft.Extensions.Options (>= 10.0.10)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.10)
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 |
|---|---|---|
| 1.10.0 | 48 | 7/27/2026 |