Skip to main content
The Gateway Agent Metrics Query API provides a flexible way to query agent-framework invocations and their outcomes: which agent ran, on which framework, on which server type, and how long it took. You can retrieve either distribution (aggregated) or timeseries results with powerful filtering and grouping.
This page covers datasource: "agentMetrics". For other datasources, see the sibling pages for Model, MCP, Guardrail, Cache, and Routing metrics.

Access control

  • Tenant admins: Can query metrics for the entire organization (tenant-wide).
  • Users: Can query their own data and their teams’ data.
  • Virtual accounts: Can query their own data and their teams’ data; with tenant-admin permissions, they can access tenant-wide data.
The server applies RBAC automatically; callers don’t pass any RBAC fields.

Contents

Authentication

You need to authenticate with your TrueFoundry API key. You can use either a Personal Access Token (PAT) or Virtual Account Token (VAT).
To generate an API key:
  1. Personal Access Token (PAT): Go to Access → Personal Access Tokens in your TrueFoundry dashboard
  2. Virtual Account Token (VAT): Go to Access → Virtual Account Tokens (requires admin permissions)
For detailed authentication setup, see our Authentication guide.

Quick Start

By default, agent metrics include every Gateway request, not just agent invocations. Rows that didn’t go through an agent will have agentName, agentFramework, and agentServerType set to null and surface in groupBy output as null buckets. The IS_NULL operator is not supported on these three fields; to scope a query to a known set of agents, filter with {"fieldName": "agentName", "operator": "IN", "value": ["<your-agent>"]} or use STRING_* operators.

Distribution query

p50 and p99 latency per agent:

Timeseries query

Hourly p99 latency per agent, restricted to failed invocations:

API reference

Endpoint

Post JSON to this endpoint with Authorization: Bearer <your_api_key> and Content-Type: application/json.

Request parameters

string
required
ISO 8601 timestamp marking the inclusive lower bound of the query window.
string
required
ISO 8601 timestamp marking the exclusive upper bound of the query window.
string
required
The data source to query. Use "agentMetrics" for Gateway agent metrics.
string
required
The type of query to execute:
  • "distribution": returns aggregated rows (one row per groupBy combination).
  • "timeseries": returns time-bucketed rows. Requires interval.
array
Array of { type, column } objects describing the aggregations to compute. When omitted, only the implicit total = COUNT(*) is returned.Supported aggregation typesSupported aggregation columns
array
Array of field names to group results by. Custom metadata keys are supported with a metadata. prefix.Available group-by fields
When groupBy contains userEmail (without virtualaccount), the server auto-injects WHERE CreatedBySubjectType = 'user'. virtualaccount alone auto-injects 'virtualaccount'. When both appear, scope it yourself with createdBySubjectType if needed.
array
Array of filter objects, AND-combined. See Filtering for the full operator reference and the per-field allow-list.
string
Required for timeseries queries. Bucket size as <positive integer> <unit>, where <unit> is one of second, minute, hour, day, week, month, year (with or without a trailing s). Examples: "30 second", "5 minute", "1 hour", "1 day". Compound expressions like "1 hour 30 minute" are rejected.
number
deprecated
Deprecated alias for interval. Accepts a positive integer number of seconds. Prefer interval in new code. If both are provided, interval wins.