Advanced Search Syntax
Advanced Search is the query box on the Traces and Logs pages. It uses the Apache Lucene query syntax: conditions written as field:value, joined with AND, OR and NOT.
1ServiceName:checkout AND Duration:>500msOpen it with the </> tile at the right of the search bar. As you type, the suggestions offer the fields, the operators that fit each field, and its values.
Slow requests of one service, built from the suggestions.

Error logs that mention a timeout.

Search syntax#
A query is one or more conditions. A condition is a field, a colon and a value.
1ServiceName:checkoutConditions are combined with boolean operators:
| Operator | Description | Example |
|---|---|---|
AND | Both conditions must match. A space between conditions means the same. | ServiceName:checkout AND Duration:>500ms |
OR | Either condition may match. | SeverityText:ERROR OR SeverityText:WARN |
NOT or - | The condition must not match. | -SpanName:health |
( ) | Groups conditions. Without brackets, AND binds before OR. | (ServiceName:checkout OR ServiceName:cart) AND Duration:>1s |
A value that contains spaces or symbols goes in double quotes.
1SpanName:"GET /api/orders"Fields#
Built-in fields have plain names.
- Traces:
ServiceName,SpanName,Duration,StatusCode,StatusCodeString,SpanKind,TraceId,SpanId,ParentSpanId - Logs:
ServiceName,SeverityText,Body,TraceId,SpanId
Attributes carry a prefix that says which part of the span or log they come from.
| Prefix | Reads | Example |
|---|---|---|
span. | Span attributes (traces) | span.http.status_code:500 |
resource. | Resource attributes (traces and logs) | resource.k8s.namespace.name:prod |
event. | Span events, such as exceptions (traces) | event.exception.type:TimeoutException |
link. | Span links (traces) | link.trace_id:4bf92f35* |
log. | Log attributes (logs) | log.request.id:8f3c2a |
scope. | Instrumentation scope (logs) | scope.name:io.opentelemetry.http |
Pick http.status_code from the suggestions and the bar writes span.http.status_code. An attribute that is not listed still works when typed in full.
Text search#
Text fields hold free text: SpanName, StatusMessage, span.db.query.text, exception messages and the log Body. On these fields, a value matches words.
Body:timeoutmatches the word anywhere in the message.Body:"connection refused"matches the two words in that order.Body:"connection refused"~3matches them within three words of each other.SpanName.keyword:"GET /api/orders"matches the whole span name, character for character.
A word typed on its own searches the span name on Traces and the message on Logs.
1timeoutWildcards#
*stands for any number of characters.?stands for one character.
1ServiceName:check*
2ServiceName:*out*
3ServiceName:checkou?Wildcard matches ignore case. Inside quotes, * and ? are plain characters.
Numerical values#
Compare numbers and durations with >, >=, < and <=.
1span.http.status_code:>=500
2Duration:>500msSearch a range with [a TO b]. Square brackets include the ends, curly brackets exclude them, and * leaves an end open.
1Duration:[100ms TO 2s]
2span.http.status_code:[400 TO 499]
3Duration:[1s TO *]Durations take ns, us, ms, s, m or h. A bare number means milliseconds.
Regular expressions#
Write the pattern between slashes, in RE2 syntax. On an exact field the pattern must match the whole value; on a text field it is searched for.
1ServiceName:/check(out|in)/
2Body:/user [0-9]+ locked/Add ~ to a word to allow one typo, or ~2 to allow two.
1ServiceName:chekout~Escaping special characters#
Quote a value that contains a space or any of these characters: : " ( ) [ ] { } ~ ^ * ?
1Body:"[ERROR] disk full"
2SpanName:"AND"Inside quotes, write a literal " or \ with a backslash in front.
[ and { only open a range, directly after a field. Typed anywhere else they are not accepted.
Autocomplete#
The suggestions follow what you type.
- Fields: type part of a name to narrow the list.
- Operators: after
field:, the ways to match that fit the field. - Values: the most frequent values in the selected time range.
- Combine: after a finished condition,
AND,OR,NOTor the next field.
Under the bar, Searching for: reads the query back in plain words. If an attribute or value is not listed, keep typing it and choose Find attributes containing "…" or Fetch values starting with "…" at the bottom of the list.
Examples#
| To find | Search |
|---|---|
| Errors from one service | ServiceName:checkout AND StatusCodeString:Error |
| Server errors | span.http.status_code:>=500 |
| Spans that recorded an exception | event.exception.type:* |
| Slow spans of one route | span.http.route:"/api/orders" AND Duration:>1s |
| Slow database calls | span.db.system:* AND Duration:>200ms |
| Queries that touch a table | span.db.query.text:orders |
| Writes only | span.http.method:(POST OR PUT OR DELETE) |
| Several services | ServiceName:(checkout OR payments OR cart) |
| Root spans of one trace | TraceId:4bf92f3577b34da6a3ce929d0e0e4736 AND NOT ParentSpanId:* |
| Everything except health checks | -SpanName:health |
| To find | Search |
|---|---|
| Errors | SeverityText:ERROR |
| Warnings and errors from one service | ServiceName:checkout AND SeverityText:(WARN OR ERROR) |
| A word in the message | Body:timeout |
| An exact phrase | Body:"connection refused" |
| Both words, in any order | Body:timeout AND Body:retry |
| A pattern in the message | Body:/user [0-9]+ locked/ |
| Errors from one namespace | resource.k8s.namespace.name:prod AND SeverityText:ERROR |
| One pod | resource.k8s.pod.name:checkout-7d9f* |
| Every line of one request | log.request.id:8f3c2a |
| Everything except debug | -SeverityText:DEBUG |