Prometheus exporter

Configure the Prometheus metrics exporter


Enable and configure the Prometheus exporter for metrics in the GraphOS Router or Apollo Router Core.

For general metrics configuration, refer to Router Metrics Configuration .

Prometheus configuration

To export metrics to Prometheus, enable the Prometheus endpoint and set its address and path in router.yaml :

YAML
router.yaml
1telemetry:
2  exporters:
3     metrics:
4       prometheus:
5         enabled: true
6         listen: 127.0.0.1:9090
7         path: /metrics

Once enabled, you will be able to access the Prometheus endpoint at http://localhost:9090/metrics.

You can configure your APM agent to scrape the metrics from the endpoint. See the documentation for your APM agent for more details.

enabled

Set to true to enable the Prometheus exporter. Defaults to false.

listen

The address and port to listen on for Prometheus metrics. Defaults to 127.0.0.1.

path

The path to expose the Prometheus metrics. Defaults to /metrics.

Prometheus configuration reference

AttributeDefaultDescription
enabledfalseEnable the Prometheus exporter.
listen127.0.0.1:9090The address to serve Prometheus metric on.
path/metricsThe path to serve Prometheus metrics on.

Using Prometheus with containers

The Prometheus endpoint listens to 127.0.0.1 by default, which won't allow connections issued from a network.

While this is a safe default, other containers won't be able to access the Prometheus endpoint, which will disable metric scraping.

You can enable other containers to access it by setting the endpoint to listen to 0.0.0.0:

YAML
router.yaml
1telemetry:
2  exporters:
3     metrics:
4       prometheus:
5         # By setting this endpoint you enable other containers and pods to access the Prometheus endpoint
6         enabled: true
7         listen: 0.0.0.0:9090 #highlight-line
8         path: /metrics

You can validate your setting locally:

  1. Run a query against the router.

  2. Navigate to http://localhost:9090/metrics , and check that the endpoint returns metrics similar to the following:

    Text
    1# HELP apollo_router_http_request_duration_seconds Total number of HTTP requests made.
    2# TYPE apollo_router_http_request_duration_seconds histogram
    3apollo_router_http_request_duration_seconds_bucket{le="0.5"} 1
    4apollo_router_http_request_duration_seconds_bucket{le="0.9"} 1
    5---SNIP---
 note
If you haven't run a query against the router yet, you'll see a blank page because no metrics have been generated.