Skip to main content
Glama

Aggregate Spans

aggregate_spans
Read-onlyIdempotent

Aggregate spans into RED metrics: request count, error rate, throughput, and latency percentiles (p50/p90/p95/p99), grouped by operation and optionally its immediate parent.

START HERE for "where are errors / latency concentrated?", "what changed between two windows?", "is this operation slow?". By default this reads a pre-aggregated rollup, so it stays cheap over wide windows: minute resolution for the last 45 days, hourly beyond that (up to 400 days). Drill into raw spans (spans / get_trace) once this points you at a specific (service, operation).

Parent breakdown: the same operation behaves differently per caller. Add "parent_operation" to groupBy to split an operation by its immediate parent — e.g. "http.client" might be 8% errors overall but 92% under one caller and 0% under others. The parent breakdown is computed on demand over raw spans, so keep it scoped: pass a tight from/to and a service/name filter when using it.

Params: from, to: ISO-8601 window (required). step: "", units s m h d w mo y (e.g. "30s", "15m", "2h", "1d", "1w", "1mo", "1y") — omit for a single window per group. groupBy: any of service, operation, parent_operation (default service, operation). service / name: optional filters.

Returns buckets[], each with group, spanCount/okCount/errorCount/unsetCount, errorRate (percentage, 0-100), throughputPerSecond, avg/min/maxDurationNanos, and quantileNanos (p50/p90/p95/p99), plus queryStats, and truncatedRows + truncationHint when buckets were dropped from the end to fit maxChars.

With a step, every bucket of the window is present for every group the result mentions: a bucket with no spans comes back with spanCount 0, so a series that stopped ends in empty buckets rather than on its last populated one.

Input Schema

NameRequiredDescriptionDefault
toYesEnd of window, ISO-8601 instant (exclusive)
fromYesStart of window, ISO-8601 instant (inclusive)
nameNoFilter by operation name
stepNoTime bucket <amount><unit>, units: s m h d w mo y (e.g. 30s, 15m, 2h, 1d, 1w, 1mo, 1y); omit for one window
groupByNoGroup-by keys: service, operation, parent_operation
serviceNoFilter by service
maxCharsNoCharacter budget for the whole response; buckets are dropped from the end to fit and truncatedRows says how many. Omit for the server ceiling.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changed
    • addedInput schema / $schema
      Added value: +"https://json-schema.org/draft/2020-12/schema"
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / maxChars / format
      Added value: +"int32"
  2. Added
  3. Removed
  4. First observed

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already cover the safety profile (readOnly, idempotent, non-destructive), yet the description adds substantial behavior beyond them: default reads a pre-aggregated rollup with minute resolution for 45 days and hourly up to 400 days, parent breakdown is computed on demand over raw spans (a real cost) and needs scoping, and truncation is surfaced via truncatedRows/truncationHint. It also documents the empty-bucket behavior for a series that stopped.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loads the purpose and the 'START HERE' routing before any detail, and organizes the rest into labeled sections (Parent breakdown, Params, Returns) that an agent can skim. It is on the long side for a read tool, and the Returns paragraph partly duplicates schema-described fields, but almost every clause carries usable information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, yet the description fully specifies the return shape (buckets[] with group, spanCount/okCount/errorCount/unsetCount, errorRate 0-100, throughputPerSecond, durations, quantileNanos, queryStats) plus truncation and empty-bucket semantics. Combined with resolution limits and drill-down guidance, nothing needed to call or interpret the tool is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds genuine meaning: it explains what groupBy actually does, and specifically that adding parent_operation splits an operation by its immediate caller with a concrete '8% overall vs 92% under one caller' example. The step units and defaults are largely repeated from the schema, keeping it short of a 5.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb+resource+output contract: 'Aggregate spans into RED metrics: request count, error rate, throughput, and latency percentiles (p50/p90/p95/p99)'. It explicitly distinguishes itself from siblings spans/get_trace as the starting point, and from metric-style tools by naming the concrete outputs an agent will get.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

States explicit triggering questions ('where are errors / latency concentrated?', 'what changed between two windows?') and then names the alternative path: drill into raw spans via spans/get_trace once pointed at a specific (service, operation). It also gives a when-to-use caveat for the expensive parent breakdown ('keep it scoped: pass a tight from/to and a service/name filter').

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources