For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
View and customize metrics
View and monitor agentgateway metrics for traffic, LLM, MCP, and connection insights.
Agentgateway exposes a Prometheus-compatible metrics endpoint on port 15020. Metrics are collected automatically for every request that passes through the gateway.
View metrics
The metrics endpoint is available at port 15020 by default.
curl http://localhost:15020/metricsMetrics are grouped under the agentgateway_ prefix and follow the OpenMetrics format. For an overview of available metrics, see the metrics reference.
For instructions on setting up Prometheus to scrape agentgateway metrics, see Prometheus.
Metrics format
The proxy’s /metrics endpoint returns metrics in one of two formats, based on the Accept header that the scraper sends. Scrapers use the Content-Type header of the response to decide how to parse the metrics, so the header must match the format.
OpenMetrics text format
By default, the endpoint returns metrics in the OpenMetrics text format. An OpenMetrics response ends with # EOF. In the response, counter samples end in _total, but the matching # TYPE line does not.
The proxy sets the Content-Type header to application/openmetrics-text only when the scraper requests OpenMetrics. The proxy sets the header to text/plain when the scraper sends one of the following:
- No
Acceptheader. - An
Acceptheader with a wildcard, such as*/*. - An
Acceptheader that requeststext/plain. - An
Acceptheader that requests only types that the proxy does not support.
Scrapers that rely on the Content-Type header then parse the response as classic Prometheus text and can drop metrics without an error. For example, the Datadog Agent without use_latest_spec: true drops every counter, while gauges and histograms still arrive. To avoid dropped metrics, use one of the following options:
- Configure your scraper to send the
Accept: application/openmetrics-text; version=1.0.0header. - In the Datadog
openmetricscheck for the proxy, setuse_latest_spec: true. - Upgrade to version 1.7 or later, which sets the
Content-Typeheader toapplication/openmetrics-textby default.
Prometheus, the OpenTelemetry Collector Prometheus receiver, and Grafana Alloy request OpenMetrics by default and need no changes. Scrapers that cannot parse OpenMetrics, such as the Vector prometheus_scrape source, are not supported.
Prometheus protobuf format
The endpoint returns metrics in the Prometheus protobuf format when the scraper requests protobuf, such as Prometheus with native histograms enabled. The proxy sets the Content-Type header to application/vnd.google.protobuf, so the scraper needs no extra configuration.
Add custom metric labels
You can enrich all metrics with custom labels that are computed from CEL expressions. Labels are added to every metric that carries the route identifier labels.
The following example adds two labels to all metrics:
env: '"production"': Adds a static label. The outer single quotes are YAML, the inner double quotes are the CEL string literal, so every metric getsenv="production"appended.user_id: 'request.headers["x-user-id"]': Adds a dynamic label. The CEL expression reads thex-user-idheader from the incoming request, souser_idin the metric reflects whoever made the request.
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
config:
metrics:
fields:
add:
env: '"production"'
user_id: 'request.headers["x-user-id"]'Remove metrics
To reduce cardinality or storage, you can exclude specific metrics by name:
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
config:
metrics:
remove:
- agentgateway_upstream_call_duration_secondsMetric names can be supplied with or without the _total and unit suffixes. Agentgateway automatically matches all variants.