Jaeger Sql jaeger-sql
Write the sql input of find_traces or find_spans: the statement shapes, the columns, the values and the predicates, including OR, NOT, a comparison on an attribute, a text pattern, and a condition on a span's events or links. Read it before the first call to either tool.
- Our test
- —
- not tested yet
- GitHub stars
- 23k
- jaegertracing/jaeger
- Added by
- 0
- members
- Updated
- Dec 6
- commit 01b47bb
- Content
- 1 file
- no scripts · 5 KB
- License
- Apache 2.0
- free to use
What our test found
Not tested yet. Our model tries every skill on a realistic request and scores the result, the most popular skills first. Until then, the safety checks on the right still apply.
name: jaeger-sql description: >- Write the sql input of find_traces or find_spans: the statement shapes, the columns, the values and the predicates, including OR, NOT, a comparison on an attribute, a text pattern, and a condition on a span's events or links. Read it before the first call to either tool. allowed-tools: find_traces find_spans
Jaeger SQL
Find traces or spans with one read-only SELECT in the sql input of find_traces or find_spans. The statement is compiled to Jaeger's filter; nothing is executed as SQL. find_traces returns traces, so it takes the first and third shapes below. find_spans returns spans, so it takes the second.
Three statement shapes
SELECT * is the only select list over spans and over traces; a column list is refused by both tools. SELECT DISTINCT trace_id FROM spans is the one other form.
Trace IDs of the traces that have a matching span:
SELECT DISTINCT trace_id
FROM spans s
WHERE between(s.start_time, now() - '1h', now()) -- required: both bounds
AND s.service = 'checkout'
AND s.duration > '500ms'
AND s.attributes['http.status_code'] >= 500
LIMIT 20The matching spans themselves, in an order:
SELECT *
FROM spans s
WHERE between(s.start_time, now() - '1h', now())
AND s.service = 'checkout'
ORDER BY s.duration DESC -- start_time, duration, trace_id, span_id
LIMIT 100Whole traces, selected by the spans they contain. The subquery is a spans query as above without ORDER BY or LIMIT; the outer WHERE takes nothing else:
SELECT *
FROM traces
WHERE trace_id IN (
SELECT trace_id
FROM spans s
WHERE between(s.start_time, now() - '1h', now())
AND s.service = 'checkout'
)
LIMIT 20Columns
Column names are snake_case and match exactly.
spans
| Column | Type | Values | |---|---|---| | trace_id, span_id, parent_span_id | text | lower-case hex; a root span has no parent_span_id, and no comparison on it matches a root span | | name | text | any | | status_message | text | any; a span without a status message has no value, so no comparison on it matches that span | | trace_state | text | any; a span without a trace state has no value, so no comparison on it matches that span | | kind | word | 'server', 'client', 'producer', 'consumer', 'internal', 'unspecified' | | status | word | 'ok', 'error', 'unset' | | start_time, end_time | instant | RFC 3339 '2026-10-23T12:00:00Z', or now() - '1h' | | duration | duration | Go syntax with a unit: '2s', '250ms', '1h30m' | | service | text | the service name | | scope_name, scope_version | text | the instrumentation scope; a span whose scope has an empty name or version has no value for that column, so no comparison on it matches that span | | attributes['key'] | map | span attributes; the value is compared at the type storage holds | | resource_attributes['key'] | map | resource attributes | | scope_attributes['key'] | map | scope attributes |
Every attribute predicate names its level. When the level is unknown, attributes['key'] is the first choice.
events and links, inside EXISTS only
| Relation | Columns | |---|---| | events | name text, time instant, time_since_start duration, attributes['key'] map | | links | linked_trace_id and linked_span_id hex text, trace_state text (a link without a trace state has no value, so no comparison on it matches that link), attributes['key'] map |
traces
trace_id, root_service, root_name, start_time, duration, span_count, error_count. These columns may not be filtered on, and find_traces returns the whole summary of each trace, so write SELECT *; a column list is refused. The only WHERE on traces is trace_id IN (SELECT trace_id FROM spans WHERE ...).
Values
- Strings
'text'. Numbers.true,false. - A duration needs a unit. An instant is RFC 3339 or
now() - '1h'.
Predicates
=, <>, <, <=, >, >=, IN (...), NOT IN, between(x, a, b), AND, OR, NOT, parentheses.
- Text search:
x LIKE 'GET %'with%and_as in SQL,x ILIKE 'get %'to ignore case, orx REGEXP 'pat'/match(x, 'pat')in RE2 syntax. A regex matches anywhere in the value unless it starts with^or ends with$(anchors elsewhere are refused), and is case-sensitive unless it starts with(?i). - Presence:
attributes['key'] IS NOT NULL, andIS NULLfor absence. They also apply to a column that can have no value, soparent_span_id IS NULLselects root spans. A column every span has, such asname, is refused. - Events and links of the span:
EXISTS (SELECT 1 FROM events WHERE name = 'exception' AND attributes['exception.type'] = 'TimeoutError'). InsideEXISTS,eventsandlinksare this span's own; no join condition is needed.
Not supported
JOIN, GROUP BY, aggregates, OFFSET, arithmetic, CAST, any function other than between, match, phrase, fulltext and now, and any relation other than spans and traces in FROM. An error names the construct, its line and column, and what to write instead.