Skip to content
Help guide the future of agentgateway — Take the survey

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

Page as Markdown

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/metrics

Metrics 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 Accept header.
  • An Accept header with a wildcard, such as */*.
  • An Accept header that requests text/plain.
  • An Accept header 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.0 header.
  • In the Datadog openmetrics check for the proxy, set use_latest_spec: true.
  • Upgrade to version 1.7 or later, which sets the Content-Type header to application/openmetrics-text by 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 gets env="production" appended.
  • user_id: 'request.headers["x-user-id"]': Adds a dynamic label. The CEL expression reads the x-user-id header from the incoming request, so user_id in 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_seconds

Metric names can be supplied with or without the _total and unit suffixes. Agentgateway automatically matches all variants.

Was this page helpful?
Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate ↵ select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.