OpenTelemetry.Exporter.Prometheus.HttpListener
1.17.0-beta.1
Prefix Reserved
dotnet add package OpenTelemetry.Exporter.Prometheus.HttpListener --version 1.17.0-beta.1
NuGet\Install-Package OpenTelemetry.Exporter.Prometheus.HttpListener -Version 1.17.0-beta.1
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.HttpListener" Version="1.17.0-beta.1" />
<PackageVersion Include="OpenTelemetry.Exporter.Prometheus.HttpListener" Version="1.17.0-beta.1" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.HttpListener" />
paket add OpenTelemetry.Exporter.Prometheus.HttpListener --version 1.17.0-beta.1
#r "nuget: OpenTelemetry.Exporter.Prometheus.HttpListener, 1.17.0-beta.1"
#:package OpenTelemetry.Exporter.Prometheus.HttpListener@1.17.0-beta.1
#addin nuget:?package=OpenTelemetry.Exporter.Prometheus.HttpListener&version=1.17.0-beta.1&prerelease
#tool nuget:?package=OpenTelemetry.Exporter.Prometheus.HttpListener&version=1.17.0-beta.1&prerelease
Prometheus Exporter HttpListener for OpenTelemetry .NET
An OpenTelemetry Prometheus exporter that configures an HttpListener instance for Prometheus to scrape.
This component is intended for dev inner-loop, there is no plan to make it production ready. 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 the HttpListener class 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
Installation
Step 1: Install Package
dotnet add package --prerelease OpenTelemetry.Exporter.Prometheus.HttpListener
Step 2: Add PrometheusHttpListener
var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter(MyMeter.Name)
.AddPrometheusHttpListener()
.Build();
Configuration
You can configure the PrometheusHttpListener through
PrometheusHttpListenerOptions and environment variables. The
PrometheusHttpListenerOptions setters take precedence over the environment
variables.
Configuration using Properties
Host: The host used by the Prometheus exporter (defaultlocalhost).Port: The port used by the Prometheus exporter (default9464).ScopeInfoEnabled: Whether to include scope labels in metrics (defaulttrue).ScrapeEndpointPath: Defines the Prometheus scrape endpoint path. (default"/metrics").TargetInfoEnabled: Whether to produce atarget_infometric (defaulttrue).ResourceConstantLabels: A predicate selecting which resource attributes are added to each metric as constant labels (defaultnull).DisableTotalNameSuffixForCounters: Whether to disable the_totalsuffix for counter metrics (defaultfalse).TranslationStrategy: Controls how OpenTelemetry metric and label names are translated into Prometheus names (defaultUnderscoreEscapingWithSuffixes). See TranslationStrategy below.DisableTimestamp: Whether to disable the timestamp for metrics (defaultfalse).ConfigureHttpListener: A delegate that can be used to apply custom configuration to theHttpListenerinstance used by the exporter before use.
Configuration using Dependency Injection
This exporter allows easy configuration of PrometheusHttpListenerOptions from
the dependency injection container, when used in conjunction with
OpenTelemetry.Extensions.Hosting.
For example:
var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter(MyMeter.Name)
.AddPrometheusHttpListener(options =>
{
options.Host = "localhost";
options.Port = 9464;
})
.Build();
Configuration using Environment Variables
The following environment variables can be used to override the default
values of the PrometheusHttpListenerOptions.
| Environment variable | PrometheusHttpListenerOptions property |
|---|---|
OTEL_EXPORTER_PROMETHEUS_HOST |
Host |
OTEL_EXPORTER_PROMETHEUS_PORT |
Port |
ScopeInfoEnabled
Specifies whether metrics include
scope labels.
Default value: true. Set to false to disable scope labels.
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.
var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter(MyMeter.Name)
.AddPrometheusHttpListener(options =>
{
// Add all resource attributes as metric labels.
options.ResourceConstantLabels = static _ => true;
})
.Build();
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 | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.0)
- OpenTelemetry (>= 1.17.0 && < 2.0.0)
-
.NETStandard 2.0
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.0)
- OpenTelemetry (>= 1.17.0 && < 2.0.0)
-
net10.0
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.0)
- OpenTelemetry (>= 1.17.0 && < 2.0.0)
-
net8.0
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 8.0.0)
- OpenTelemetry (>= 1.17.0 && < 2.0.0)
-
net9.0
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 9.0.0)
- OpenTelemetry (>= 1.17.0 && < 2.0.0)
NuGet packages (18)
Showing the top 5 NuGet packages that depend on OpenTelemetry.Exporter.Prometheus.HttpListener:
| Package | Downloads |
|---|---|
|
OpenTelemetry.AutoInstrumentation.Runtime.Managed
Managed components used by the OpenTelemetry.AutoInstrumentation project. |
|
|
Elvia.Telemetry
Common logging/telemetry functionality to used by all services within the Elvia ecosystem. |
|
|
conductor-csharp
C# sdk for conductor |
|
|
Bones.Monitoring
Package Description |
|
|
Redpoint.CloudFramework
A framework for building ASP.NET Core applications on top of Google Cloud Firestore in Datastore mode. Not only does this framework provide a model-based API for interacting with Google Cloud Firestore, it contains useful implementations of things like database migrations, distributed locks, geographic indexes and sharded counters. |
GitHub repositories (8)
Showing the top 8 popular GitHub repositories that depend on OpenTelemetry.Exporter.Prometheus.HttpListener:
| Repository | Stars |
|---|---|
|
prometheus-net/prometheus-net
.NET library to instrument your code with Prometheus metrics
|
|
|
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
|
|
|
open-telemetry/opentelemetry-dotnet-contrib
This repository contains set of components extending functionality of the OpenTelemetry .NET SDK. Instrumentation libraries, exporters, and other components can find their home here.
|
|
|
axzxs2001/Asp.NetCoreExperiment
原来所有项目都移动到**OleVersion**目录下进行保留。新的案例装以.net 5.0为主,一部分对以前案例进行升级,一部分将以前的工作经验总结出来,以供大家参考!
|
|
|
cocosip/sharp-abp
Abp-vNext extension modules
|
|
|
RedpointGames/uet
UET (Unreal Engine Tool) makes building and testing Unreal Engine projects and plugins easy. It can distribute builds with BuildGraph, remotely execute automation tests on device and across multiple machines, handles fault tolerance and automatic retries and generally makes the whole experience of automating Unreal Engine a lot more pleasant.
|
|
|
osstotalsoft/nbb
.Net Building Blocks
|
|
|
Particular/docs.particular.net
All content for ParticularDocs
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.17.0-beta.1 | 1,391 | 7/16/2026 |
| 1.16.0-beta.1 | 61,051 | 6/10/2026 |
| 1.15.3-beta.1 | 780,524 | 4/21/2026 |
| 1.15.2-beta.1 | 49,246 | 4/8/2026 |
| 1.15.1-beta.1 | 30,518 | 3/27/2026 |
| 1.15.0-beta.1 | 400,171 | 1/21/2026 |
| 1.14.0-beta.1 | 806,831 | 11/12/2025 |
| 1.13.1-beta.1 | 96,325 | 10/10/2025 |
| 1.13.0-beta.1 | 9,632 | 10/1/2025 |
| 1.12.0-beta.1 | 1,589,280 | 5/6/2025 |
| 1.11.2-beta.1 | 961,822 | 3/5/2025 |
| 1.11.0-beta.1 | 194,181 | 1/16/2025 |
| 1.10.0-beta.1 | 182,415 | 11/12/2024 |
| 1.9.0-beta.2 | 1,569,007 | 6/24/2024 |
| 1.9.0-beta.1 | 803,500 | 6/14/2024 |
| 1.9.0-alpha.2 | 84,110 | 5/29/2024 |
| 1.9.0-alpha.1 | 9,183 | 5/20/2024 |
| 1.8.0-rc.1 | 1,078,419 | 3/27/2024 |
| 1.8.0-beta.1 | 16,558 | 3/14/2024 |
| 1.7.0-rc.1 | 834,354 | 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.HttpListener/CHANGELOG.md.