Configuring the OpenTelemetry Collector to ingest metrics via OTLP push and Prometheus scrape with example configs, application code, logs, and troubleshooting tips
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.
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.
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:
Collector debug output when receiving pushed metrics (cleaned and truncated for clarity):
otel-collector | 2025-09-30T00:12:22.523Z info service@v0.135.0/service.go:211 Starting otelcol-contrib...otel-collector | 2025-09-30T00:12:22.523Z info extensions/extensions.go:41 Starting extensions..otel-collector | 2025-09-30T00:12:22.523Z info otlpreceiver@v0.135.0/otlpreceiver.go:121 Starting GRPC server {"endpoint":"[::]:4317"}otel-collector | 2025-09-30T00:12:22.524Z info otlpreceiver@v0.135.0/otlpreceiver.go:179 Starting HTTP server {"endpoint":"[::]:4318"}otel-collector | 2025-09-30T00:12:22.534Z info service@v0.135.0/service.go:234 Everything is ready. server
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.
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:
Collector logs when starting and scraping (important parts):
otel-collector | 2025-09-30T10:09:45Z info otlpreceiver@v0.135.0/otlpreceiver.go:121 Starting gRPC server {"endpoint":"[::]:4317"}otel-collector | 2025-09-30T10:09:45Z info otlpreceiver@v0.135.0/otlpreceiver.go:179 Starting HTTP server {"endpoint":"[::]:4318"}otel-collector | 2025-09-30T10:09:45Z info service@v0.135.0/service.go:234 Everything is ready. Begin running and processing data
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.
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.