Searching Spans and Logs

In addition to the SQL-like query language, Uptrace allows you to search spans and logs using a more concise and natural query language that makes finding specific data faster and more intuitive.

Word Filters

The simplest query is a single word that must be found within the search scope.

Example: The query error will match the following logs:

text
err
error
ERROR
ERRor
an error just occurred

Multiple Words (AND Logic)

When your query contains multiple words separated by spaces, all words must be found in the search scope.

Example: The query error select will match:

text
error select
select error
an error has occurred when executing a select query

Multiple Words (OR Logic)

To search for logs containing any of multiple words, separate them with the pipe character (|).

Example: The query select|update will match:

text
select
update
select update

Phrase Filters

To search for logs containing an exact phrase, enclose the phrase in double quotes ("). The phrase can contain any characters, including spaces, punctuation, and special characters.

Example: The query "select query" will match:

text
an error has occurred when executing a select query
select query

But will not match:

text
query select
selecting a query

Regular Expression Filters

To search using regular expressions, prefix your expression with the tilde character (~).

Example: The query ~err will match:

text
err
error
an_err
some error

Regular Expressions with Spaces

If your regular expression contains spaces, enclose it in backticks (`):

Example:

text
~`\d{4} \w+`

Negative Filters

To exclude logs containing specific words or phrases, prefix the term with a minus sign (-).

Example: The query error -ssh will find error logs that do not contain the word ssh.

Combining Filters

You can combine multiple filter types in a single query:

Example: error "database connection" -timeout ~\d{3} will find logs that:

  • Contain the word "error"
  • Contain the exact phrase "database connection"
  • Do not contain the word "timeout"
  • Match the regular expression \d{3} (three digits)

Search Scope

The search scope defines which attributes Uptrace searches when filtering spans and logs. By default, the search scope corresponds to your current grouping expression.

Default Search Scopes

Grouping ExpressionSearch Scope
group by _group_iddisplay_name
group by service_name, host_nameservice_name, host_name
group by _group_id, service_namedisplay_name, service_name

Custom Search Scopes

You can specify custom search scopes for any filter type by using the attribute:value syntax:

Examples:

text
host_name:host1
service_name:"hello world"
~span_name:user.*
message:-"connection failed"

This allows you to search specific attributes regardless of your current grouping configuration.

Filter Syntax Reference

Filter TypeSyntaxDescriptionExample
WordwordMatches logs containing the worderror
Multiple words (AND)word1 word2All words must be presenterror database
Multiple words (OR)word1|word2Any word must be presenterror|warning
Phrase"phrase"Exact phrase match"connection timeout"
Regular expression~patternRegex pattern match~\d{3}-\d{3}-\d{4}
Regular expression with spaces~`pattern` Regex with spaces~`error \d+`
Negative filter-termExcludes logs with term-debug
Scoped filterattribute:valueSearch specific attributehost_name:prod-server

Tips for Effective Searching

  • Case insensitive: All text searches are case-insensitive by default
  • Partial matching: Word filters match partial words (e.g., err matches error)
  • Combine filters: Use multiple filter types together for precise results
  • Use quotes: Always quote phrases and values containing spaces or special characters
  • Escape special characters: In regex patterns, remember to escape special characters as needed