- Push-based (OTLP) — your application pushes metrics to the Collector.
- Pull-based (Prometheus-style) — the Collector scrapes your application for metrics.
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 thereceivers and the service.pipelines.metrics section that wires receivers into the metrics pipeline.
- The
prometheusreceiver uses Prometheus-stylescrape_configsso the Collector behaves like Prometheus and pulls metrics frompython-app:8000. - The
otlpreceiver 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
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:
debug exporter prints pushed metrics it may show:
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 theprometheus_client library). The Collector scrapes that endpoint using the Prometheus receiver.
Example Python configuration using PrometheusMetricReader:
debug exporter prints scraped metrics. Example (truncated):
/metrics endpoint from python-app:8000 and the debug exporter displayed the metrics.
Common pitfalls and fixes
Tips:
- You can enable both OTLP push and Prometheus scraping simultaneously by listing both
otlpandprometheusin themetricspipeline. - When troubleshooting, the
debugexporter 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
/metricsendpoint 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.
debug exporter.
Links and References
- OpenTelemetry Collector: https://opentelemetry.io/docs/collector/
- OTLP protocol: https://opentelemetry.io/docs/reference/specification/protocol/otlp/
- Prometheus docs: https://prometheus.io/
- Python prometheus_client: https://github.com/prometheus/client_python
- OpenTelemetry Python metrics: https://opentelemetry.io/docs/instrumentation/python/metrics/