Zupit.Prometheus
1.0.0
dotnet add package Zupit.Prometheus --version 1.0.0
NuGet\Install-Package Zupit.Prometheus -Version 1.0.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="Zupit.Prometheus" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Zupit.Prometheus --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Zupit.Prometheus, 1.0.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.
// Install Zupit.Prometheus as a Cake Addin #addin nuget:?package=Zupit.Prometheus&version=1.0.0 // Install Zupit.Prometheus as a Cake Tool #tool nuget:?package=Zupit.Prometheus&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Zupit.Prometheus
This library adds an endpoint to your ASP.NET Core application that returns metrics in the Prometheus format with a token-based authentication.
The endpoint is accessible via GET /metrics
Prerequisites
- .NET 7 or later
Installation
dotnet add package Zupit.Prometheus
Configuration
In your appsettings.json
file, add the following configuration:
{
"Metrics": {
"TokenKey": "your-query-param-token-key",
"TokenValue": "your-token-value"
}
}
For example:
{
"Metrics": {
"TokenKey": "token",
"TokenValue": "cV^96k"
}
}
configures the endpoint to be accessible via GET /metrics?token=cV^96k
.
If the token is not provided or is incorrect, the endpoint will return a 404 Not Found
response.
Usage
In your Program.cs
file, add the following code:
using Zupit.Prometheus;
var builder = WebApplication.CreateBuilder(args);
// Add Prometheus metric services (with configuration validation on start)
builder.Services.AddPrometheusMetrics(builder.Configuration);
...
var app = builder.Build();
...
// Add the Prometheus endpoint with token auth
app.MapPrometheusEndpointWithToken();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- OpenTelemetry.Exporter.Prometheus.AspNetCore (>= 1.6.0-rc.1)
- OpenTelemetry.Extensions.Hosting (>= 1.6.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.6.0)
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- OpenTelemetry.Exporter.Prometheus.AspNetCore (>= 1.7.0-rc.1)
- OpenTelemetry.Extensions.Hosting (>= 1.7.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.7.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.