Skip to main content
This guide demonstrates how to configure the OpenTelemetry Collector to receive metrics using two common approaches:
  • Push-based (OTLP) — your application pushes metrics to the Collector.
  • Pull-based (Prometheus-style) — the Collector scrapes your application for metrics.
Below are compact, corrected Collector configuration and application examples used in the demo, followed by representative Collector console output showing metrics ingestion. Use these snippets to validate both ingestion models and to troubleshoot common issues.
This article shows two common ways to get metrics into the Collector: OTLP push and Prometheus scrape. You can enable both simultaneously by configuring both receivers and adding them to your metrics pipeline.

Collector: common pieces

The Collector configuration below contains attribute enrichment, an OTLP receiver, a Prometheus receiver (for scraping), processors, and exporters. The critical parts for metrics are the receivers and the service.pipelines.metrics section that wires receivers into the metrics pipeline.
Key points:
  • The prometheus receiver uses Prometheus-style scrape_configs so the Collector behaves like Prometheus and pulls metrics from python-app:8000.
  • The otlp receiver accepts OTLP over both gRPC and HTTP (useful for client push exporters).
  • For metrics ingestion, make sure the receiver(s) are listed under service.pipelines.metrics.receivers.

Quick comparison: Push vs Pull

AspectPush (OTLP)Pull (Prometheus scrape)
How metrics arriveApplication pushes to Collector via OTLPCollector scrapes /metrics endpoint
Typical endpointhttp://collector:4318/v1/metricshttp://your-app:8000/metrics
Use caseInstrumented apps pushing telemetry (e.g., SDK exporters)Existing Prometheus exporters or instrumented apps exposing /metrics
Collector roleOTLP receiver (HTTP/gRPC)Prometheus receiver (scraper)
Good forShort-lived batches, centralized pushingLong-lived services with Prometheus exposition

Push-based metrics (OTLP)

For push-based metrics, configure an OTLP metrics exporter in your application to send metrics to the Collector. When using the HTTP OTLP exporter, provide the full URL including /v1/metrics. Example Python configuration using OTLP HTTP metrics exporter and a periodic metric reader:
Create observable gauges in the app (example):
Run the application:
Collector debug output when receiving pushed metrics (cleaned and truncated for clarity):
When the Collector’s debug exporter prints pushed metrics it may show:
This verifies successful push-based ingestion: the app exported metrics to http://localhost:4318/v1/metrics, the Collector received them via its OTLP HTTP receiver, and the debug exporter printed them.

Pull-based metrics (Prometheus scraping)

For Prometheus-style scraping, your application exposes an HTTP endpoint that returns Prometheus-formatted metrics (commonly using the prometheus_client library). The Collector scrapes that endpoint using the Prometheus receiver. Example Python configuration using PrometheusMetricReader:
Observable gauges and Flask integration example:
Start the app:
Collector logs when starting and scraping (important parts):
After scraping (every 15s as configured), the debug exporter prints scraped metrics. Example (truncated):
This confirms successful scraping: the Prometheus receiver pulled the /metrics endpoint from python-app:8000 and the debug exporter displayed the metrics.

Common pitfalls and fixes

SymptomLikely causeFix / Tip
No metrics in pipelineReceiver defined but not added to service.pipelines.metricsAdd the receiver name to service.pipelines.metrics.receivers
OTLP HTTP exporter fails to sendIncorrect endpoint pathUse full path: http://host:4318/v1/metrics
Prometheus static target not foundMissing port or wrong addressEnsure static_configs.targets includes port, e.g., python-app:8000
Scraped metrics missing labelsPrometheus exposition missing metadataConfirm exporter/library sets desired labels (e.g., service.name)
Tips:
  • You can enable both OTLP push and Prometheus scraping simultaneously by listing both otlp and prometheus in the metrics pipeline.
  • When troubleshooting, the debug exporter is very helpful to observe exactly what the Collector receives.

Summary

  • Push-based (OTLP): App pushes metrics to the Collector using an OTLP exporter (often HTTP to /v1/metrics). See the OTLP protocol docs: https://opentelemetry.io/docs/reference/specification/protocol/otlp/
  • Pull-based (Prometheus): App exposes a /metrics endpoint and the Collector scrapes it via the Prometheus receiver. See Prometheus: https://prometheus.io/
  • The Collector can accept both approaches simultaneously—configure both receivers and add them to service.pipelines.metrics.receivers.
With the configuration and code snippets above you can validate both ingestion models and observe metrics via the Collector’s debug exporter.

Watch Video