Skip to content

Latest commit

 

History

History
65 lines (46 loc) · 2.53 KB

File metadata and controls

65 lines (46 loc) · 2.53 KB

Prometheus Exporter HttpListener for OpenTelemetry .NET

NuGet NuGet

An OpenTelemetry Prometheus exporter that configures an HttpListener instance for Prometheus to scrape.

Warning: this component is intended for dev inner-loop, there is no plan to make it production ready. Production environments should use OpenTelemetry.Exporter.Prometheus.AspNetCore, or a combination of OpenTelemetry.Exporter.OpenTelemetryProtocol and OpenTelemetry Collector.

Prerequisite

Steps to enable OpenTelemetry.Exporter.Prometheus.HttpListener

Step 1: Install Package

dotnet add package --prerelease OpenTelemetry.Exporter.Prometheus.HttpListener

Step 2: Add PrometheusHttpListener

var meterProvider = Sdk.CreateMeterProviderBuilder()
    .AddMeter(MyMeter.Name)
    .AddPrometheusHttpListener(
        options => options.UriPrefixes = new string[] { "http://localhost:9464/" })
    .Build();

UriPrefixes

Defines one or more URI (Uniform Resource Identifier) prefixes which will be used by the HTTP listener. The default value is ["http://localhost:9464/"].

Refer to HttpListenerPrefixCollection.Add(String) for more details.

ScrapeEndpointPath

Defines the Prometheus scrape endpoint path. Default value: "/metrics".

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