Comparison operators
Every TraceQL query is built from spanset filters: conditions in curly braces that select spans by attribute or intrinsic value. Attributes take a leading dot (.service_name), with optional resource. and span. scopes; intrinsics such as name and duration are unprefixed.
Equal (=)
Selects spans where an attribute or intrinsic equals the given value. Attribute names take a leading dot (.service_name); scoped forms (resource., span.) restrict where the attribute is looked up. String values are quoted; numbers, durations, and enums like span kind are not.
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Required |
The span or resource attribute, or an intrinsic such as |
|
Required |
Quoted string, number, duration ( |
Example
Find traces containing spans from the demo-python-service.
{.service_name = "demo-python-service"}
| Root service | Root span | Duration |
|---|---|---|
demo-python-service |
database |
51 ms |
demo-python-service |
database |
50 ms |
demo-python-service |
database |
50 ms |
|
An unscoped attribute ( |
Not equal (!=)
Selects spans where an attribute or intrinsic is not equal to the given value. Combine with a positive condition to keep the search scoped.
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Required |
The attribute or intrinsic to test. |
|
Required |
The value to exclude. |
Example
Find demo traces from every service except the Python one.
{.service_name =~ "demo.*" && .service_name != "demo-python-service"}
| Root service | Root span | Duration |
|---|---|---|
demo-java-service |
database |
50 ms |
demo-java-service |
database |
50 ms |
demo-java-service |
database |
50 ms |
|
Spans that do not carry the attribute at all do not match a |
Regex not match (!~)
Selects spans where an attribute or intrinsic does not match an RE2 regular expression — exclude several values with one condition.
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Required |
The attribute or intrinsic to test. |
|
Required |
Matching spans are excluded. |
Example
Find demo spans whose operation name does not start with data — the user spans match, the database spans do not.
{.service_name =~ "demo.*" && name !~ "data.*"}
| Root service | Root span | Duration |
|---|---|---|
demo-go-service |
database |
50 ms |
demo-go-service |
database |
50 ms |
demo-go-service |
database |
50 ms |
Ordering comparisons (>, >=, <, ⇐)
Compares numeric attributes and duration intrinsics with >, >=, <, and ⇐. Durations take Go-style units (100ms, 2s); the most common use is latency filtering on the duration intrinsic.
Regex match (=~)
Selects spans where an attribute or intrinsic matches an RE2 regular expression — one condition for a whole family of values.
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Required |
The attribute or intrinsic to test. |
|
Required |
An RE2 regular expression. |
Example
Match all three demo services with a single expression.
{.service_name =~ "demo-.*-service"}
| Root service | Root span | Duration |
|---|---|---|
demo-java-service |
database |
50 ms |
demo-python-service |
database |
50 ms |
demo-java-service |
database |
50 ms |
|
RE2 does not support look-ahead or back-references. |