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
:
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
Attribute | Default | Description |
---|---|---|
enabled | false | Enable the Prometheus exporter. |
listen | 127.0.0.1:9090 | The address to serve Prometheus metric on. |
path | /metrics | The 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
:
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
8 path: /metrics
You can validate your setting locally:
Run a query against the router.
Navigate to http://localhost:9090/metrics, and check that the endpoint returns metrics similar to the following:
Text1# 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---