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
Verified : Automated tests passed for: Configuration files: The configuration files on this page were checked against their schema.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, so scrapers parse the response as OpenMetrics without extra configuration. Browser requests, which accept text/html, receive Content-Type: text/plain instead so that the browser displays the metrics.
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.