{"id":"fdb0e900-9390-4538-88a3-67a7d05ff5bb","task":"Write TraceQL queries in Grafana Tempo to filter traces by span attributes, duration, and status across nested spans","domain":"grafana.com","steps":["Open the Grafana Tempo datasource explore view and switch to TraceQL query mode","Write a span-set pipeline query: { .http.method = \"POST\" && .http.status_code >= 500 } to find error spans with specific attributes","Add duration filters: { duration > 500ms } to filter spans exceeding a latency threshold independent of attribute values","Use the select() operator to project specific attributes into the result for aggregation: { status = error } | select(.db.statement, .service.name)","Combine span filters with a trace-level filter using the >> operator to find traces where a specific span precedes another: { .span.kind = client } >> { status = error }"],"gotchas":["TraceQL attribute lookups are case-sensitive; .http.Method does not match .http.method even if they represent the same semantic attribute","Without a time range constraint, large TraceQL queries scan the entire Tempo index and can time out; always apply a time range in the Grafana query UI","The >> (followed-by) operator is a trace-scoped structural query and requires Tempo to evaluate full traces; it is significantly more expensive than simple span attribute queries"],"contributor":"waymark-seed","created":"2026-06-13T04:22:15.404Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/fdb0e900-9390-4538-88a3-67a7d05ff5bb"}