![]() |
VOOZH | about |
dotnet add package Prometheus.Client.Abstractions --version 6.3.0
NuGet\Install-Package Prometheus.Client.Abstractions -Version 6.3.0
<PackageReference Include="Prometheus.Client.Abstractions" Version="6.3.0" />
<PackageVersion Include="Prometheus.Client.Abstractions" Version="6.3.0" />Directory.Packages.props
<PackageReference Include="Prometheus.Client.Abstractions" />Project file
paket add Prometheus.Client.Abstractions --version 6.3.0
#r "nuget: Prometheus.Client.Abstractions, 6.3.0"
#:package Prometheus.Client.Abstractions@6.3.0
#addin nuget:?package=Prometheus.Client.Abstractions&version=6.3.0Install as a Cake Addin
#tool nuget:?package=Prometheus.Client.Abstractions&version=6.3.0Install as a Cake Tool
👁 ci
👁 nuget
👁 nuget
👁 codecov
👁 license
.NET Client library for prometheus.io
It is hard fork of prometheus-net from early 2017 that has since evolved into a different library.
Our main goals:
You can find the benchmark descriptions.
dotnet add package Prometheus.Client
| Name | Description |
|---|---|
| Prometheus.Client.AspNetCore | ASP.NET Core middleware |
| Prometheus.Client.DependencyInjection | Dependency Injection extensions |
| Prometheus.Client.HttpRequestDurations | Metrics logging of request durations |
| Prometheus.Client.MetricPusher | Push metrics to Prometheus PushGateway |
| Prometheus.Client.MetricPusher.HostedService | MetricPusher as HostedService |
| Prometheus.Client.HealthChecks | HealthChecks Publisher |
| Prometheus.Client.MetricServer | Standalone Kestrel server |
| Prometheus.Client.Owin | Owin middleware |
Add metrics endpoint without extension:
[Route("[controller]")]
public class MetricsController : Controller
{
private readonly ICollectorRegistry _registry;
public MetricsController(ICollectorRegistry registry)
{
_registry = registry;
}
[HttpGet]
public async Task Get()
{
Response.StatusCode = 200;
await using var outputStream = Response.Body;
await ScrapeHandler.ProcessAsync(_registry, outputStream);
}
}
Add metrics endpoint with Prometheus.Client.AspNetCore:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime appLifetime)
{
app.UsePrometheusServer();
}
IMetricFactory and ICollectorRegistry can be added to DI container with Prometheus.Client.DependencyInjection:
public void ConfigureServices(IServiceCollection services)
{
services.AddMetricFactory();
}
For collect http requests, use Prometheus.Client.HttpRequestDurations. It does not depend on Prometheus.Client.AspNetCore, however together it's very convenient to use:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime appLifetime)
{
app.UsePrometheusServer();
app.UsePrometheusRequestDurations();
}
Four types of metric are offered: Counter, Gauge, Summary and Histogram.
See the documentation on metric types
and instrumentation best practices
on how to use them.
Counters go up, and reset when the process restarts.
var counter = metricFactory.CreateCounter("myCounter", "some help about this");
counter.Inc(5.5);
Gauges can go up and down.
var gauge = metricFactory.CreateGauge("gauge", "help text");
gauge.Inc(3.4);
gauge.Dec(2.1);
gauge.Set(5.3);
Summaries track the size and number of events.
var summary = metricFactory.CreateSummary("mySummary", "help text");
summary.Observe(5.3);
Histograms track the size and number of events in buckets. This allows for aggregate calculation of quantiles.
var hist = metricFactory.CreateHistogram("my_histogram", "help text", buckets: new[] { 0, 0.2, 0.4, 0.6, 0.8, 0.9 });
hist.Observe(0.4);
The default buckets are intended to cover a typical web/rpc request from milliseconds to seconds.
They can be overridden passing in the buckets argument.
All metrics can have labels, allowing grouping of related time series.
See the best practices on naming and labels.
Taking a counter as an example:
var counter = metricFactory.CreateCounter("myCounter", "help text", labelNames: new []{ "method", "endpoint"});
counter.WithLabels("GET", "/").Inc();
counter.WithLabels("POST", "/cancel").Inc();
Since v4 there is alternative new way to provide a labels via ValueTuple that allow to reduce memory allocation:
var counter = metricFactory.CreateCounter("myCounter", "help text", labelNames: ("method", "endpoint"));
counter.WithLabels(("GET", "/")).Inc();
counter.WithLabels(("POST", "/cancel")).Inc();
Contributions to the package are always welcome!
Entity Framework Extensions is a major sponsor and is proud to contribute to this project.
All contents of this package are licensed under the MIT license.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 is compatible. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 2 NuGet packages that depend on Prometheus.Client.Abstractions:
| Package | Downloads |
|---|---|
|
Prometheus.Client
.NET client for Prometheus |
|
|
Itselves.AlertManager.Prometheus
Library for alert manager which use prometheus like a provider |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 6.3.0 | 21,850 | 3/10/2026 |
| 6.2.0 | 4,762 | 2/15/2026 |
| 6.1.0 | 239,255 | 5/29/2025 |
| 6.0.0 | 127,827 | 5/24/2025 |
| 5.2.0 | 3,933,191 | 1/5/2023 |
| 5.1.0 | 413,343 | 9/11/2022 |
| 5.0.0 | 1,037,225 | 8/21/2022 |
| 4.5.3 | 1,260,469 | 9/20/2021 |
| 4.5.2 | 685,751 | 7/14/2021 |
| 4.5.1 | 156,866 | 7/12/2021 |
| 4.5.0 | 1,830 | 7/10/2021 |
| 4.4.0 | 245,361 | 3/11/2021 |
| 4.3.0 | 207,237 | 1/29/2021 |