Skip to main content
This guide shows how to push metrics from an OpenTelemetry Collector to Prometheus using Prometheus’ remote write receiver. The stack uses Docker Compose to run the Collector, Prometheus, and Jaeger (for traces). You’ll learn how to:
  • Add Prometheus to Docker Compose and enable the remote write receiver
  • Provide a Prometheus configuration suitable for receiving pushed metrics
  • Configure the OpenTelemetry Collector to export metrics via prometheusremotewrite
  • Start the stack and validate metrics in the Prometheus UI
This demonstration uses Prometheus’ remote write API so the OpenTelemetry Collector can push metrics directly into Prometheus. Use this when you want the Collector to push metrics rather than having Prometheus scrape targets.

Overview

  • Add a Prometheus service to your Docker Compose file and enable the remote-write HTTP receiver.
  • Mount a simple prometheus.yml that sets global intervals (no scrape_configs needed if the Collector pushes metrics).
  • Configure the Collector with a prometheusremotewrite exporter that targets Prometheus at http://prometheus:9090/api/v1/write.
  • Start the stack and verify metrics at http://localhost:9090.

1) Add Prometheus to Docker Compose

Update docker-compose.yml to include Jaeger and Prometheus services, and configure Prometheus to enable the remote write receiver:
Ports exposed by the stack:
ServicePurpose / UIPort (host:container)
JaegerUI / tracing16686:16686
PrometheusUI / metrics9090:9090
JaegergRPC14250:14250
JaegerHTTP14268:14268
JaegerAgent (UDP)6831:6831/udp, 6832:6832/udp
Notes:
  • The --web.enable-remote-write-receiver flag enables Prometheus to accept pushed metrics at /api/v1/write.
  • We mount a local prometheus.yml to control Prometheus behavior from your project directory.

2) Create Prometheus configuration (prometheus.yml)

If the Collector is pushing metrics to Prometheus, you do not need scrape_configs. Create prometheus.yml beside your docker-compose.yml:
Why no remote_write section? The remote_write stanza in Prometheus is for sending metrics out to remote storage. In this setup, Prometheus acts as the receiver — the HTTP endpoint /api/v1/write — which is enabled by the CLI flag above, not by prometheus.yml. Helpful reference:

3) Configure the OpenTelemetry Collector to export metrics via Prometheus remote_write

Add a prometheusremotewrite exporter to your Collector configuration (example filename: collector-config.yaml or otel-collector-config.yaml) and include it in the metrics pipeline. Example Collector config:
Key points:
  • Exporter name: prometheusremotewrite (this is the Collector exporter that POSTs to Prometheus’ /api/v1/write).
  • Endpoint: http://prometheus:9090/api/v1/write. When running under Docker Compose, the Collector can resolve the prometheus hostname (service name) on the default network.
  • Keep a debug exporter if you want to inspect metrics in the Collector logs while simultaneously pushing them to Prometheus.
  • The otlp/jaeger exporter forwards traces to Jaeger on port 14250.

4) Bring up the stack

Start the services in detached mode:
Verify containers are running:
Useful container logs and checks:
ActionCommand
Prometheus logsdocker-compose logs prometheus
Collector logsdocker-compose logs <collector-service-name>
Show running containersdocker-compose ps
Prometheus UI: http://localhost:9090
Jaeger UI: http://localhost:16686

5) Validate metrics in Prometheus UI

  1. Open http://localhost:9090.
  2. In the “Expression” input, search for metrics emitted by your application. Example metric names from a sample app:
    • current_temperature_fahrenheit_degF
    • current_humidity_percentage
  3. Run queries to confirm metrics are visible and being updated.
If metrics are missing, check:
  • The Collector is running and its metrics pipeline includes the prometheusremotewrite exporter.
  • The endpoint in the Collector exporter is http://prometheus:9090/api/v1/write.
  • Prometheus was started with --web.enable-remote-write-receiver and the mounted prometheus.yml is valid.
  • Services are on the same Docker Compose network so hostnames resolve between containers.
Troubleshooting tips
  • Use the Collector debug exporter (configured above) to see metric payloads in logs.
  • Inspect Prometheus logs for errors related to /api/v1/write.
  • Confirm the Collector and Prometheus containers can reach each other by running a quick curl from within the Collector container:
    • Enter the container: docker exec -it <collector-container> /bin/sh
    • Test connectivity: curl -v http://prometheus:9090/api/v1/write
  • Ensure no firewall or host port conflicts exist on 9090.
References and further reading This completes the end-to-end setup for pushing metrics from an OpenTelemetry Collector to Prometheus using Prometheus’ remote write receiver.

Watch Video

Practice Lab