opamp-core

Prometheus And Collector Setup For Provider Metrics

This page shows how to scrape the provider metrics endpoint from Prometheus or an OpenTelemetry Collector.

Endpoint summary

For machine-to-machine scraping, the simplest secure setup is a static bearer token:

{
  "provider": {
    "ui-use-authorization": "config-token",
    "metrics": {
      "enabled": true,
      "graph_history_minutes": 15
    },
    "tls": {
      "cert_file": "/etc/opamp/provider.pem",
      "key_file": "/etc/opamp/provider-key.pem"
    }
  }
}

Environment:

export UI_AUTH_STATIC_TOKEN="replace-with-a-scrape-token"

Why this is usually the best fit:

If your environment already uses an identity provider for non-OpAMP routes, provider.ui-use-authorization=idp also works, but the scraper must then send a valid bearer token accepted by that IdP configuration.

Prometheus example

global:
  scrape_interval: 30s

scrape_configs:
  - job_name: opamp-provider
    scheme: https
    metrics_path: /metrics
    static_configs:
      - targets:
          - opamp.example.org:8443
    authorization:
      type: Bearer
      credentials: ${OPAMP_PROVIDER_METRICS_TOKEN}
    tls_config:
      ca_file: /etc/prometheus/certs/provider-ca.pem

Adjust as needed:

OpenTelemetry Collector example

The Collector’s Prometheus receiver accepts Prometheus-style scrape_configs, so the setup is very similar:

receivers:
  prometheus:
    config:
      scrape_configs:
        - job_name: opamp-provider
          scheme: https
          metrics_path: /metrics
          static_configs:
            - targets:
                - opamp.example.org:8443
          authorization:
            type: Bearer
            credentials: REPLACE_WITH_SCRAPE_TOKEN
          tls_config:
            ca_file: /etc/otel/certs/provider-ca.pem

processors:
  batch: {}

exporters:
  debug: {}

service:
  pipelines:
    metrics:
      receivers: [prometheus]
      processors: [batch]
      exporters: [debug]

Notes:

Local development example

If you are using the repository default config from config/opamp.json, the provider currently exposes:

That means a local Prometheus scrape can be as small as:

scrape_configs:
  - job_name: opamp-provider-local
    static_configs:
      - targets:
          - localhost:8080

Internal graph data for product dashboards

If you want the provider itself to retain gauge history for built-in dashboards:

{
  "provider": {
    "metrics": {
      "enabled": true,
      "graph_history_minutes": 15
    }
  }
}

Behavior:

Example query:

/api/metrics/graphs?metric=opamp_provider_clients_total

Troubleshooting

References