search_traces
Search CubeAPM traces by service, environment, time range, and query filters to find slow or failing requests and return key span snippets for investigation.
Instructions
Search for traces in CubeAPM matching the specified criteria. Returns trace snippets with key spans.
IMPORTANT - Required Parameters:
query, env, service, start, end are ALL REQUIRED by CubeAPM API
Use query="*" for wildcard search
Use env="UNSET" if environment is not configured
Service names are case-sensitive (e.g., "Kratos-Prod" not "kratos")
TRACE QUERY SYNTAX: The query parameter supports pipe syntax similar to LogsQL: {stream_selector} | pipe1 | pipe2
Stream selectors filter spans: {service="Kratos-Prod"} {service="Kratos-Prod", span_kind="server"} {http_code=~"5.."}
PIPE OPERATORS — same as LogsQL pipes: | copy, | drop, | extract_regexp, | join, | keep, | limit, | math, | rename, | replace, | replace_regexp, | sort, | stats as alias [by (group_fields)], | unpack_json
STATS FUNCTIONS (for aggregate trace analysis): avg(field) — arithmetic mean count() — total matching spans count_uniq(field) — distinct values max(field) — maximum value median(field) — median value min(field) — minimum value quantile(p, field) — p-th quantile (e.g., quantile(0.95, duration)) sum(field) — sum of values
IMPORTANT: Duration in traces is in MILLISECONDS. IMPORTANT: "p95" is NOT a valid function — use quantile(0.95, duration).
Example queries: Wildcard: query="*" P95 latency: query='{service="Kratos-Prod", span_kind="server"} | stats quantile(0.95, duration) as p95_latency' Error count by endpoint: query='{service="Kratos-Prod", status_code="ERROR"} | stats count() as errors by (http_route)' Slow spans: query='{service="Kratos-Prod"} | sort by (duration) desc | limit 20'
Optional filters (applied in addition to query):
spanKind: server, client, consumer, producer
sortBy: duration (to find slow traces)
To discover available service names, first query metrics: count by (service) (cube_apm_calls_total{env="UNSET"})
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"service": "<service>",
"start": "<start>",
"end": "<end>"
},
"name": "search_traces"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end | Yes | End timestamp in RFC3339 format or Unix seconds | |
| env | No | Environment name (use UNSET if not configured) | UNSET |
| limit | No | Maximum number of traces to return | |
| query | No | The traces search query (use * for wildcard) | * |
| start | Yes | Start timestamp in RFC3339 format or Unix seconds | |
| sortBy | No | Sort results by: duration | |
| service | Yes | Service name to filter by (REQUIRED, case-sensitive) | |
| spanKind | No | Filter by span kind: server, client, consumer, producer |