Send Metrics from Prometheus Clients

If you have a system that is instrumented as a Prometheus client, you can use OpenTelemetry Collector to scrape metrics data from that client’s endpoint and send it to a Honeycomb dataset.

How It Works 

Prometheus is a widely adopted open source metrics server with its own API and client libraries. Prometheus clients expose their metrics on an HTTP endpoint. Prometheus servers can then connect to that endpoint and store the metrics they provide. OpenTelemetry Collector acts like a Prometheus server, and will transform Prometheus metrics signals into OpenTelemetry Metrics signals, which can then be forwarded to Honeycomb over the OpenTelemetry Line Protocol (OTLP).

An architecture diagram depicting an instrumented app exposing a Prometheus endpoint, which is being scraped by OpenTelemetry Collector. OpenTelemetry Collector is then sending data to Honeycomb over OTLP.

Instrumenting Your Application as a Prometheus Client 

Refer to the Prometheus documentation to find details about the appropriate client library for your application.

Installing and Running OpenTelemetry Collector 

Find and download a recent release of OpenTelemetry Collector from the Releases page on GitHub.

OpenTelemetry Collector requires a configuration file to run (find more details below). If your configuration file exists in the current working directory at otel_collector_config.yaml, you can then run it using the following command:

otel-collector --config $(pwd)/otel_collector_config.yaml

See more about using OpenTelemetry Collector with Honeycomb.

Configuring OpenTelemetry Collector 

To scrape Prometheus endpoints, you will need to configure OpenTelemetry Collector with a pipeline that starts with a prometheus receiver. To forward scraped metrics to Honeycomb, your pipeline should end with an otlp exporter. Pipelines are specified in an OpenTelemetry Collector configuration file. Here is a bare bones example of a configuration file configured to scrape prometheus metrics and send them to Honeycomb:

receivers:
  prometheus:
    config:
      scrape_configs:
        - job_name: "prometheus"
          scrape_interval: 15s
          static_configs:
            - targets: ["0.0.0.0:9100"] # this is the endpoint to scrape

exporters:
  otlp/metrics:
    endpoint: "api.honeycomb.io:443" # US instance
    #endpoint: "api.eu1.honeycomb.io:443" # EU instance
    headers:
      "x-honeycomb-team": "YOUR_API_KEY"
      "x-honeycomb-dataset": "DESTINATION_DATASET_NAME"

service:
  pipelines:
    metrics:
      receivers: [prometheus]
      processors: []
      exporters: [otlp/metrics]