{"id":548,"library":"opentelemetry-exporter-prometheus","title":"OpenTelemetry Prometheus Exporter","description":"The `opentelemetry-exporter-prometheus` library provides a Prometheus Metric Exporter for OpenTelemetry, allowing applications instrumented with OpenTelemetry to expose their metrics in a format that a Prometheus server can scrape. It is part of the larger OpenTelemetry Python project, currently at version 0.61b0, and is under active development with frequent releases.","status":"active","version":"0.61b0","language":"python","source_language":"en","source_url":"https://github.com/open-telemetry/opentelemetry-python","tags":["observability","metrics","prometheus","opentelemetry","exporter"],"install":[{"cmd":"pip install opentelemetry-exporter-prometheus opentelemetry-sdk prometheus_client","lang":"bash","label":"Install with SDK and Prometheus client"}],"dependencies":[{"reason":"Required for OpenTelemetry metric collection and MeterProvider setup.","package":"opentelemetry-sdk"},{"reason":"Used by the exporter to start the HTTP server for Prometheus scraping.","package":"prometheus_client"}],"imports":[{"symbol":"PrometheusMetricReader","correct":"from opentelemetry.exporter.prometheus import PrometheusMetricReader"},{"symbol":"MeterProvider","correct":"from opentelemetry.sdk.metrics import MeterProvider"},{"symbol":"PeriodicExportingMetricReader","correct":"from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader"},{"symbol":"Resource, SERVICE_NAME","correct":"from opentelemetry.sdk.resources import Resource, SERVICE_NAME"},{"symbol":"start_http_server","correct":"from prometheus_client import start_http_server"}],"quickstart":{"code":"import os\nimport time\nfrom opentelemetry import metrics\nfrom opentelemetry.sdk.metrics import MeterProvider\nfrom opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader\nfrom opentelemetry.exporter.prometheus import PrometheusMetricReader\nfrom opentelemetry.sdk.resources import Resource, SERVICE_NAME\nfrom prometheus_client import start_http_server\n\n# Configure the MeterProvider with the PrometheusMetricReader\n# PrometheusMetricReader starts an HTTP server, typically on port 9464.\n# Ensure this port is available or configure a different one.\nreader = PrometheusMetricReader()\nprovider = MeterProvider(\n    resource=Resource.create({\n        SERVICE_NAME: os.environ.get('OTEL_SERVICE_NAME', 'my-prometheus-service')\n    }),\n    metric_readers=[reader]\n)\nmetrics.set_meter_provider(provider)\n\n# Start the Prometheus HTTP server for scraping\n# By default, it serves on 0.0.0.0:9464/metrics\nstart_http_server(port=9464, addr='0.0.0.0')\n\n# Get a meter from the MeterProvider\nmeter = metrics.get_meter(__name__)\n\n# Create a counter instrument\nrequests_counter = meter.create_counter(\n    name='requests_total',\n    description='Total number of requests',\n    unit='1'\n)\n\nprint(\"Prometheus exporter running on http://localhost:9464/metrics\")\nprint(\"Press Ctrl+C to exit\")\n\n# Simulate work and increment the counter\nwhile True:\n    requests_counter.add(1, {\"route\": \"/\", \"method\": \"GET\"})\n    time.sleep(1)\n","lang":"python","description":"This quickstart demonstrates how to set up the OpenTelemetry Prometheus Exporter. It initializes a `MeterProvider` with a `PrometheusMetricReader` which automatically starts an HTTP server on port 9464 (by default) that Prometheus can scrape. It then creates a simple counter and increments it periodically, exposing the metric for Prometheus to collect. Remember to set the `OTEL_SERVICE_NAME` environment variable for better metric identification."},"warnings":[{"fix":"Always pin to exact versions (`==x.y.z`) and review changelogs thoroughly during upgrades. Consider using the OpenTelemetry Collector for production environments if API stability is critical.","message":"The `opentelemetry-exporter-prometheus` package is currently in 'beta' and is marked as 'experimental'. New releases may introduce breaking changes to its API or behavior before it reaches a stable (1.0) release.","severity":"breaking","affected_versions":"<1.0"},{"fix":"Be aware of the translation rules when querying metrics in Prometheus. Consult the OpenTelemetry documentation on Prometheus compatibility and metric naming normalization.","message":"OpenTelemetry and Prometheus have different naming conventions. The exporter automatically translates OpenTelemetry metric and attribute names to comply with Prometheus rules (e.g., dots become underscores, units and `_total` suffixes are added for counters). This can lead to unexpected metric names in Prometheus.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your OpenTelemetry SDK configuration for metrics uses cumulative temporality, which is often the default for OTLP export. Review temporality settings if metrics are missing or appear incorrect.","message":"Prometheus primarily supports cumulative counter metrics. If OpenTelemetry metrics are configured to export as delta temporality, they may not be correctly interpreted or displayed in Prometheus.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For production or larger scale environments, it is generally recommended to use an OpenTelemetry Collector. Applications can export metrics to the Collector via OTLP, and the Collector can then expose them to Prometheus via its own Prometheus exporter, offering more flexibility and control.","message":"The direct SDK export of Prometheus metrics, while simple, may not scale well for large applications or complex deployments. It forces all metrics into a single scrape endpoint, potentially leading to performance and reliability issues.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure the default port 9464 is available. If not, configure a different port for the `PrometheusMetricReader` when initializing it, or for the `start_http_server` call if used directly.","message":"The PrometheusMetricReader starts an HTTP server to expose metrics, defaulting to port 9464. If another service is already using this port, the exporter will fail to start.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.61':47 'activ':52 'allow':17 'applic':18 'b0':48 'current':44 'develop':53 'export':3,7,14,61 'expos':23 'format':28 'frequent':55 'instrument':19 'larger':40 'librari':9 'metric':13,25,58 'observ':57 'opentelemetri':1,6,16,21,41,60 'opentelemetry-exporter-prometheus':5 'part':37 'project':43 'prometheus':2,8,12,31,59 'provid':10 'python':42 'releas':56 'scrape':34 'server':32 'version':46","created_at":"2026-03-28T15:18:22.435402+00:00","updated_at":"2026-04-16T17:38:51.856147+00:00","problems":{"verify_error":"error: Failed to parse: `opentelemetry-exporter-prometheus opentelemetry-sdk prometheus_client`\n  Caused by: Expected one of `@`, `(`, `<`, `=`, `>`, `~`, `!`, `;`, found `o`\nopentelemetry-exporter-prometheus opentelemetry-sdk prometheus_client\n                                  ^"},"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":0,"quickstart_tag":"stale","pypi_latest":"0.63b1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/open-telemetry/opentelemetry-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/opentelemetry-exporter-prometheus/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["observability","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"install_fail","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-05","install_tag":"verified"}}