OpenTelemetry.Exporter.Prometheus.AspNetCore
1.17.0-beta.1
Prefix Reserved
dotnet add package OpenTelemetry.Exporter.Prometheus.AspNetCore --version 1.17.0-beta.1
NuGet\Install-Package OpenTelemetry.Exporter.Prometheus.AspNetCore -Version 1.17.0-beta.1
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.17.0-beta.1" />
<PackageVersion Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.17.0-beta.1" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" />
paket add OpenTelemetry.Exporter.Prometheus.AspNetCore --version 1.17.0-beta.1
#r "nuget: OpenTelemetry.Exporter.Prometheus.AspNetCore, 1.17.0-beta.1"
#:package OpenTelemetry.Exporter.Prometheus.AspNetCore@1.17.0-beta.1
#addin nuget:?package=OpenTelemetry.Exporter.Prometheus.AspNetCore&version=1.17.0-beta.1&prerelease
#tool nuget:?package=OpenTelemetry.Exporter.Prometheus.AspNetCore&version=1.17.0-beta.1&prerelease
Prometheus Exporter AspNetCore for OpenTelemetry .NET
An OpenTelemetry Prometheus exporter for configuring an ASP.NET Core application with an endpoint for Prometheus to scrape.
This component is still under development due to a dependency on the experimental Prometheus and OpenMetrics Compatibility specification and can undergo breaking changes before stable release. Production environments should consider using OpenTelemetry.Exporter.OpenTelemetryProtocol. Refer to the Getting Started with Prometheus and Grafana tutorial for more information.
The Prometheus scraping endpoint is not secured by default, so it is important to consider the security implications of exposing this endpoint in your application.
Refer to the Prometheus Security model and ASP.NET Core security documentation for more information and guidance on securing the Prometheus scraping endpoint to ensure only authorized users can access the information exposed by it.
Prerequisite
Steps to enable OpenTelemetry.Exporter.Prometheus.AspNetCore
Step 1: Install Package
dotnet add package --prerelease OpenTelemetry.Exporter.Prometheus.AspNetCore
Step 2: Configure OpenTelemetry MeterProvider
When using OpenTelemetry.Extensions.Hosting package on .NET 6.0+:
services.AddOpenTelemetry() .WithMetrics(builder => builder.AddPrometheusExporter());Or configure directly:
Call the
MeterProviderBuilder.AddPrometheusExporterextension to register the Prometheus exporter.var meterProvider = Sdk.CreateMeterProviderBuilder() .AddPrometheusExporter() .Build(); builder.Services.AddSingleton(meterProvider);
Step 3: Configure Prometheus Scraping Endpoint
You can use register the Prometheus scraping middleware using the
MapPrometheusScrapingEndpoint extension method on
IEndpointRouteBuilder interface with
Minimal APIs.
For example:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapPrometheusScrapingEndpoint();
You can use the IEndpointConventionBuilder returned by the extension
method to compose with other functionality, such as to exclude HTTP metrics
from the scraping endpoint itself. For example:
app.MapPrometheusScrapingEndpoint()
.DisableHttpMetrics();
If you are using the older Generic Host API
you can register the Prometheus scraping middleware with the
UseOpenTelemetryPrometheusScrapingEndpoint extension method on
IApplicationBuilder instead:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.UseOpenTelemetryPrometheusScrapingEndpoint();
Overloads of the UseOpenTelemetryPrometheusScrapingEndpoint extension are
provided to change the path or for more advanced configuration a predicate
function can be used:
app.UseOpenTelemetryPrometheusScrapingEndpoint(
context => context.Request.Path == "/internal/metrics" &&
context.Connection.LocalPort == 5067);
This can be used in combination with configuring multiple ports on the ASP.NET application to expose the scraping endpoint on a different port.
Configuration
The PrometheusExporter can be configured using the PrometheusAspNetCoreOptions
properties.
ScopeInfoEnabled
Specifies whether metrics include
scope labels.
Default value: true. Set to false to disable scope labels.
ScrapeEndpointPath
Defines the path for the Prometheus scrape endpoint for the middleware
registered by MapPrometheusScrapingEndpoint and
UseOpenTelemetryPrometheusScrapingEndpoint. Default value: "/metrics".
ScrapeResponseCacheDurationMilliseconds
Configures scrape endpoint response caching. Multiple scrape requests within the
cache duration time period will receive the same previously generated response.
The default value is 300. Set to 0 to disable response caching.
TargetInfoEnabled
Specifies whether to produce a
target_info
metric. Default value: true. Set to false to disable the target_info metric.
ResourceConstantLabels
A predicate used to select which
resource attributes
are added to each metric as constant labels. The predicate is invoked with the
resource attribute key and should return true to include the attribute.
Default value: null (no resource attributes are added as metric labels).
Resource attributes copied as metric labels are always included in the
target_info metric regardless of this predicate.
services.AddOpenTelemetry()
.WithMetrics(builder => builder
.AddPrometheusExporter(options =>
{
// Add all resource attributes as metric labels.
options.ResourceConstantLabels = static _ => true;
}));
TranslationStrategy
Controls how OpenTelemetry metric and label names are translated into Prometheus
names, following the OpenTelemetry specification's translation_strategy option.
The strategy combines two independent choices: whether discouraged characters are
escaped to _ or UTF-8 names are passed through unaltered, and whether unit and
type (e.g. _total) suffixes are appended.
| Strategy | Escaping | Suffixes |
|---|---|---|
UnderscoreEscapingWithSuffixes (default) |
Escape to _ |
Appended |
UnderscoreEscapingWithoutSuffixes |
Escape to _ |
Not appended |
NoUTF8EscapingWithSuffixes |
UTF-8 passthrough | Appended |
NoTranslation |
UTF-8 passthrough | Not appended |
The escaping choice only sets the default escaping scheme. A scrape request that
negotiates an escaping scheme (via the escaping parameter of the Accept header,
supported by the version 1.0.0 and later text formats) always takes precedence over
the configured strategy. The classic (pre-1.0.0) text formats do not support
escaping negotiation and are always emitted using underscore escaping; the suffix
choice applies to every format.
Troubleshooting
This component uses an EventSource with the name "OpenTelemetry-Exporter-Prometheus" for its internal logging. Please refer to SDK troubleshooting for instructions on seeing these internal logs.
References
| 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
- OpenTelemetry (>= 1.17.0 && < 2.0.0)
-
net8.0
- OpenTelemetry (>= 1.17.0 && < 2.0.0)
-
net9.0
- OpenTelemetry (>= 1.17.0 && < 2.0.0)
NuGet packages (162)
Showing the top 5 NuGet packages that depend on OpenTelemetry.Exporter.Prometheus.AspNetCore:
| Package | Downloads |
|---|---|
|
SharpAbp.Abp.OpenTelemetry.Exporter.Prometheus.AspNetCore
SharpAbp OpenTelemetry Module |
|
|
Elvia.Telemetry.AspNetCore
Common logging/telemetry functionality to used by all AspNetCore services within the Elvia ecosystem. |
|
|
KubeOps.Operator.Web
This is an operator sdk written in c#. It enables a developer to create a custom controller for CRDs (CustomResourceDefinitions) that runs on kubernetes. This operator uses ASP.net to support webhooks and external access to the operator. |
|
|
ShtrihM.Wattle3.OpenTelemetry
Framework for creating high-performance servers with domain object models. |
|
|
OpenTelemetryConfig
Package Description |
GitHub repositories (38)
Showing the top 20 popular GitHub repositories that depend on OpenTelemetry.Exporter.Prometheus.AspNetCore:
| Repository | Stars |
|---|---|
|
JustArchiNET/ArchiSteamFarm
C# application with primary purpose of farming Steam cards from multiple accounts simultaneously.
|
|
|
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
|
|
|
kurrent-io/KurrentDB
KurrentDB is a database that's engineered for modern software applications and event-driven architectures. Its event-native design simplifies data modeling and preserves data integrity while the integrated streaming engine solves distributed messaging challenges and ensures data consistency.
|
|
|
dotnet/samples
Sample code referenced by the .NET documentation
|
|
|
JasperFx/marten
.NET Transactional Document DB and Event Store on PostgreSQL
|
|
|
microsoft/dotnet-podcasts
.NET reference application shown at .NET Conf featuring ASP.NET Core, Blazor, .NET MAUI, Microservices, Orleans, Playwright, and more!
|
|
|
BrighterCommand/Brighter
A framework for building messaging apps with .NET and C#.
|
|
|
GZTimeWalker/GZCTF
The GZ::CTF project, an open source CTF platform.
|
|
|
meysamhadeli/booking-microservices
A practical microservices with the latest technologies and architectures like Vertical Slice Architecture, Event Sourcing, CQRS, DDD, gRpc, MongoDB, RabbitMq, Wolverine, and Aspire in .Net 10.
|
|
|
SteeltoeOSS/Steeltoe
.NET Components for Externalized Configuration, Database Connectors, Service Discovery, Logging and Distributed Tracing, Application Management, Security, and more.
|
|
|
mehdihadeli/food-delivery-microservices
🍔 A practical and cloud-native food delivery microservices, built with .Net Aspire, .Net 10, Wolverine, Domain-Driven Design, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
|
|
|
CodeMazeBlog/CodeMazeGuides
The main repository for all the Code Maze guides
|
|
|
streetwriters/notesnook-sync-server
Sync server for Notesnook (self-hosting in alpha)
|
|
|
simpleidserver/SimpleIdServer
OpenID, OAuth 2.0, SCIM2.0, UMA2.0, FAPI, CIBA & OPENBANKING Framework for ASP.NET Core
|
|
|
Aguafrommars/TheIdServer
OpenID/Connect, OAuth2, WS-Federation and SAML 2.0 server based on Duende IdentityServer and ITFoxtec Identity SAML 2.0 with its admin UI
|
|
|
NimblePros/eShopOnWeb
Sample ASP.NET Core 10.0 reference application, powered by Microsoft, demonstrating a domain-centric application architecture with monolithic deployment model.
|
|
|
Azure/Industrial-IoT
Azure Industrial IoT Platform
|
|
|
meysamhadeli/booking-modular-monolith
A practical Modular Monolith architecture with the latest technologies and architecture like Vertical Slice Architecture, Event Driven Architecture, CQRS, DDD, gRpc, Masstransit, and Aspire in .Net 10.
|
|
|
Eventuous/eventuous
Event Sourcing library for .NET
|
|
|
SlimPlanet/SlimFaas
SlimFaas : The slimmest and simplest Function As A Service
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.17.0-beta.1 | 0 | 7/16/2026 |
| 1.16.0-beta.1 | 346,050 | 6/10/2026 |
| 1.15.3-beta.1 | 1,936,868 | 4/21/2026 |
| 1.15.2-beta.1 | 202,334 | 4/8/2026 |
| 1.15.1-beta.1 | 270,894 | 3/27/2026 |
| 1.15.0-beta.1 | 1,919,101 | 1/21/2026 |
| 1.14.0-beta.1 | 1,942,075 | 11/12/2025 |
| 1.13.1-beta.1 | 987,315 | 10/10/2025 |
| 1.13.0-beta.1 | 279,696 | 10/1/2025 |
| 1.12.0-beta.1 | 4,478,362 | 5/6/2025 |
| 1.11.2-beta.1 | 3,838,058 | 3/5/2025 |
| 1.11.0-beta.1 | 2,134,199 | 1/16/2025 |
| 1.10.0-beta.1 | 1,970,548 | 11/12/2024 |
| 1.9.0-beta.2 | 10,526,281 | 6/24/2024 |
| 1.9.0-beta.1 | 680,402 | 6/14/2024 |
| 1.9.0-alpha.2 | 442,807 | 5/29/2024 |
| 1.9.0-alpha.1 | 119,452 | 5/20/2024 |
| 1.8.0-rc.1 | 5,243,757 | 3/27/2024 |
| 1.8.0-beta.1 | 349,689 | 3/14/2024 |
| 1.7.0-rc.1 | 5,765,112 | 11/30/2023 |
For highlights and announcements see: https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.17.0-beta.1/RELEASENOTES.md.
For detailed changes see: https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.17.0-beta.1/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md.