Build queries with the query builder
The query builder is available in the search field on observability pages. It appears in these areas:- On the Sessions, Errors, Logs, Traces, and Observability metrics pages.
- In the filters for alerts and custom dashboard graphs.
- In the settings for filter rules.
service_name, the operator is, and the value checkout matches data from the checkout service.

The query builder on the Traces page, with filters and the field menu open.
Add and edit filters
Here are the controls for adding, updating, and deleting filters:| Activity | Controls |
|---|---|
| Add a filter | Click an empty spot in the query builder, including the space between two filters, to display the fields, operators, and logical operators you can add at that spot. Type characters to filter the available selections. The query builder highlights the best match. Press Tab or Enter to add the highlighted option, or click a name in the menu. |
| Add a field and operator together | Type a suggested field name followed by an operator, such as service_name= or service_name is not. The query builder adds both the field and operator and moves to the value entry. You can type the operator as a symbol or as its label. |
| Add a filter for a field that isn’t suggested | Type the field name, then select the “Search for field” option. |
| Add multiple values | Use checkboxes in the menu to select multiple values, or use commas to separate multiple, typed values. |
| Update a filter | Click an existing field, operator, or value to change it. |
| Delete a filter | Click the x icon next to the filter. You can also press Backspace to delete one character at a time. Deleting the last character of a field removes the filter. |
| Run the query | Press Enter when the menu is closed. |
Operators
Each field offers the operators that apply to its type. If you select more than one value for a filter, the is and is not operators change to display is one of and is not one of. Here are the available operators and the search syntax each one produces:| Operator | Field types | Search syntax |
|---|---|---|
| exists | All | key EXISTS |
| does not exist | All | key NOT EXISTS |
| is | All | key=value |
| is not | All | key!=value |
| contains | String | key="*value*" |
| does not contain | String | key!="*value*" |
| starts with | String | key="value*" |
| ends with | String | key="*value" |
| matches | String | key="/regex/" |
| does not match | String | key!="/regex/" |
| is greater than | Numeric, duration, timestamp | key>value |
| is greater than or equal to | Numeric, duration, timestamp | key>=value |
| is less than | Numeric, duration, timestamp | key<value |
| is less than or equal to | Numeric, duration, timestamp | key<=value |
duration or fields with names that end in _duration, you can include a unit in the value: h, m, s, ms, us, or ns. For example, duration>=500ms.
Combine filters
The query builder joins filters with an implicitAND unless you add a logical operator between them. The “Operators” category in the menu includes these logical operators:
- AND: Match when both filter expressions are true.
- OR: Match when either filter expression is true.
- NOT: Exclude matches for the next filter expression.
- Logical Group: Group filter expressions in parentheses to evaluate them first.
AND, OR, or NOT followed by a space to add a logical operator. To change an existing AND to OR, or an OR to AND, click it.
To group filters with the keyboard:
- Type
(before a filter to group it with every filter after it, up to the end of the query or of the group that contains it. - Type
)inside a group to end the group there. The filters after it move out of the group. - Select filters and type
(or)to group only the selection. - Type
(after the last filter to add an empty group.
Copy and paste queries
When you copy filters from the query builder, LaunchDarkly copies them as search syntax, such asservice_name=checkout AND environment!=production. When you paste search syntax into the query builder, LaunchDarkly converts it to filters.
The page URL also stores your query in search syntax. You can share the URL to link others to your search results.
Keyboard shortcuts
Here are the keyboard shortcuts the query builder supports:| Shortcut | Action |
|---|---|
| Shift+Left arrow or Shift+Right arrow | Select filters and logical operators. |
| Cmd+A or Ctrl+A | Select all. |
| Cmd+C or Ctrl+C | Copy the selection as search syntax. |
| Cmd+X or Ctrl+X | Cut the selection. |
| Delete or Backspace | Delete the selection. |
( or ) | Group the selection in parentheses. |
| Cmd+Z or Ctrl+Z | Undo. |
| Cmd+Shift+Z, Ctrl+Shift+Z, or Ctrl+Y | Redo. |
| Left arrow or Right arrow | Move the cursor one character, or into the space between filters. |
| Alt+Left arrow or Alt+Right arrow | Move the cursor one word. |
| Cmd+Left arrow or Ctrl+Left arrow | Move to the start of the query. |
| Cmd+Right arrow or Ctrl+Right arrow | Move to the end of the query. |
| Tab or Enter | Add the highlighted option in the menu. |
| Enter | Run the query when the menu is closed. |
Search query syntax
The query builder stores each query in the search syntax that this section describes. Search syntax appears in the page URL and when you copy a query, and you can paste it into the query builder to create filters. Compose your search query with one or more expressions. Each expression can be a comparison between a key and a value, or a logical combination of other expressions. Keywords such asAND, OR, NOT, and EXISTS are not case-sensitive. For example, not exists and NOT EXISTS are equivalent.
Here are some examples of search queries:
span_name.
Keys and values
Keys are identifiers, which can include any combination of alphanumeric characters, underscores (_), periods (.), dashes (-), and wildcards, which are indicated by asterisks (*).
Values are strings with any character. To use spaces or special characters, you must enclose the string in quotes (", ').
You can use wildcards (*) in values to match on part of a pattern. For example:
span_name=gorm.*matches allspan_namevalues that start withgorm.span_name=*.Querymatches allspan_namevalues that end with.Queryspan_name=*orm*matches all values that containorm
Trace and span ID values
LaunchDarkly stores thetrace_id, span_id, and parent_span_id fields in the hexadecimal format that OpenTelemetry uses. Datadog displays the same identifiers as decimal numbers.
When you filter one of these three fields with a decimal value copied from Datadog, LaunchDarkly also matches the hexadecimal form it stored at ingest. You do not need to convert the identifier yourself. This behavior applies on the Logs, Traces, and Errors pages.
Here is an example query that uses a Datadog decimal trace ID:
Regex expressions
You can search with regex expressions by using the matches query operator:=/[your regex here]/. For example:
clickTextContent=/\w.+\w/matches allclickTextContentthat start and end with any wordbrowser_version=/\d\.\d\.\d/matches allbrowser_versionvalues in the form [0-9].[0-9].[0-9]
tag="/\w \w/"visited-url="/https://app.launchdarkly.com/\d/.+/"
Comparisons
Use operators to compare two different elements in your search query. The following operators are supported:=: Equals!=: Does not equal<: Less than<=: Less than or equal to>: Greater than>=: Greater than or equal to
Exist and does not exist
You can search if a key exists or does not exist with theEXISTS operator. For example, to return all the traces with a connected session, use the following query:
EXISTS also works with the NOT keyword. For example, when you only want the root level spans when searching traces, use this query:
AND, OR, and NOT:
AND: Both expressions must be true.OR: At least one of the expressions must be true.NOT: The following expression must be false.
AND unless you specify OR. For example:
( AND ) to group values in an expression. For example:
Span functions for trace search
The search functionality on the Traces page returns individual spans that make up traces. Span functions help you filter results to show only those spans for traces that contain or don’t contain spans that match one or more conditions. The following span functions are available when you search on the Traces page:any_span( expression )limits results to spans where the trace contains at least one span that matches the expression.any_span2()andany_span3()operate in the same way asany_span(). The unique function names let you require different spans in the trace to satisfy different conditions in the same query. To learn more, read Using multiple span aliases.no_span( expression )limits results to spans where the trace contains no spans that match the inner expression.child_span( expression )limits results to spans that have at least one direct child span matching the expression.parent_span( expression )limits results to spans where the direct parent span matches the expression.root_span( expression )limits results to spans where the trace’s root span matches the expression.
EXISTS, AND, OR, and NOT.
Here is an example that returns spans whose trace contains at least one span from the auth-service:
auth-service span:
auth-service:
checkout:
Using multiple span aliases
If you callany_span() more than once in a query, the conditions accumulate against the same span. For example, this query requires a single span in the trace to match both conditions:
any_span2() or any_span3() for the second condition. Here is an example that returns spans whose trace contains at least one checkout span and another, different span that contains errors:
Combining span functions with regular search expressions
You can combine span functions with regular search expressions in the same query. Regular expressions filter the displayed spans by their own properties, while span functions filter the displayed spans by conditions that apply to the same trace. Here is an example:production environment whose trace also contains at least one auth-service span that lasts longer than one second.
Limitations
You can only use span functions as top-level filters in a query. Span functions have the following restrictions:- You cannot wrap span functions in parentheses.
- All span functions at the top level of a query are joined with an implicit
ANDoperator. You cannot combine span functions usingAND,OR, orNOToutside of the function call.
AND, OR, NOT, EXISTS, and grouping.