OpenTelemetry.Exporter.Prometheus.AspNetCore
1.10.0-beta.1
Prefix Reserved
dotnet add package OpenTelemetry.Exporter.Prometheus.AspNetCore --version 1.10.0-beta.1
NuGet\Install-Package OpenTelemetry.Exporter.Prometheus.AspNetCore -Version 1.10.0-beta.1
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.10.0-beta.1" />
paket add OpenTelemetry.Exporter.Prometheus.AspNetCore --version 1.10.0-beta.1
#r "nuget: OpenTelemetry.Exporter.Prometheus.AspNetCore, 1.10.0-beta.1"
// Install OpenTelemetry.Exporter.Prometheus.AspNetCore as a Cake Addin #addin nuget:?package=OpenTelemetry.Exporter.Prometheus.AspNetCore&version=1.10.0-beta.1&prerelease // Install OpenTelemetry.Exporter.Prometheus.AspNetCore as a Cake Tool #tool nuget:?package=OpenTelemetry.Exporter.Prometheus.AspNetCore&version=1.10.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.
[!WARNING] 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.
[!NOTE] This exporter does not support Exemplars. For using Exemplars, use the OTLP Exporter and use a component like OTel Collector to expose metrics (with exemplars) to Prometheus. This tutorial shows one way how to do that.
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.AddPrometheusExporter
extension to register the Prometheus exporter.var meterProvider = Sdk.CreateMeterProviderBuilder() .AddPrometheusExporter() .Build(); builder.Services.AddSingleton(meterProvider);
Step 3: Configure Prometheus Scraping Endpoint
Register Prometheus scraping middleware using the
UseOpenTelemetryPrometheusScrapingEndpoint
extension method onIApplicationBuilder
: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.
ScrapeEndpointPath
Defines the path for the Prometheus scrape endpoint for the middleware
registered by
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.
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. |
-
net8.0
- OpenTelemetry (>= 1.10.0 && < 2.0.0)
-
net9.0
- OpenTelemetry (>= 1.10.0 && < 2.0.0)
NuGet packages (46)
Showing the top 5 NuGet packages that depend on OpenTelemetry.Exporter.Prometheus.AspNetCore:
Package | Downloads |
---|---|
SharpAbp.Abp.OpenTelemetry.Exporter.Prometheus.AspNetCore
SharpAbp OpenTelemetry Module |
|
ShtrihM.Wattle3.OpenTelemetry
Framework for creating high-performance servers with domain object models. |
|
Packs.Template.BaseApi
Basis for any Packs API |
|
Jakar.Database
Package Description |
|
Aguacongas.TheIdServer
OpenID/Connect , OAuth and WS-Federation server base on Duende IdentityServer. |
GitHub repositories (30)
Showing the top 5 popular GitHub repositories that depend on OpenTelemetry.Exporter.Prometheus.AspNetCore:
Repository | Stars |
---|---|
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
|
|
JustArchiNET/ArchiSteamFarm
C# application with primary purpose of farming Steam cards from multiple accounts simultaneously.
|
|
EventStore/EventStore
EventStoreDB, the event-native database. Designed for Event Sourcing, Event-Driven, and Microservices architectures
|
|
fullstackhero/dotnet-starter-kit
Production Grade Cloud-Ready .NET 8 Starter Kit (Web API + Blazor Client) with Multitenancy Support, and Clean/Modular Architecture that saves roughly 200+ Development Hours! All Batteries Included.
|
|
dotnet/samples
Sample code referenced by the .NET documentation
|
Version | Downloads | Last updated |
---|---|---|
1.10.0-beta.1 | 5,977 | 11/12/2024 |
1.9.0-beta.2 | 1,249,469 | 6/24/2024 |
1.9.0-beta.1 | 134,397 | 6/14/2024 |
1.9.0-alpha.2 | 128,110 | 5/29/2024 |
1.9.0-alpha.1 | 34,807 | 5/20/2024 |
1.8.0-rc.1 | 1,530,579 | 3/27/2024 |
1.8.0-beta.1 | 106,815 | 3/14/2024 |
1.7.0-rc.1 | 2,137,088 | 11/30/2023 |
1.7.0-alpha.1 | 131,680 | 10/17/2023 |
1.6.0-rc.1 | 2,393,950 | 8/21/2023 |
1.6.0-alpha.1 | 196,155 | 7/12/2023 |
1.5.0-rc.1 | 1,180,253 | 5/26/2023 |
1.5.0-alpha.1 | 797,292 | 3/8/2023 |
1.4.0-rc.4 | 2,021,801 | 2/11/2023 |
1.4.0-rc.3 | 113,537 | 2/2/2023 |
1.4.0-rc.2 | 120,282 | 1/9/2023 |
1.4.0-rc.1 | 201,952 | 12/12/2022 |
1.4.0-beta.3 | 313,446 | 11/7/2022 |
1.4.0-beta.2 | 252,636 | 10/17/2022 |
1.4.0-beta.1 | 70,710 | 9/30/2022 |
1.4.0-alpha.2 | 112,306 | 8/18/2022 |
For highlights and announcements see: https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.10.0-beta.1/RELEASENOTES.md.
For detailed changes see: https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.10.0-beta.1/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md.