Query Language
What is the Query Language?
A query selects targets from Steadybit's discovery data by their attributes. You use queries wherever targets need to be narrowed down: in an environment's scope, a service's target scope, an experiment's blast radius, and the target explorer.
You can write a query in two ways:
Query UI (default): pick keys and values from dropdowns. All conditions are combined with
AND, which covers simple queries like "clusterprod, namespaceshop".Query Language: write the query as text. It supports everything the Query UI does, plus
OR,NOT, parentheses, partial and case-insensitive matches, lists of values, presence checks, aggregations, and comments.
The rest of this page is about the Query Language.
How to switch between the Query UI and the Query Language

Both editors work on the same query. Switch to the Query Language tab, and the query you built in the Query UI is translated into text, ready to extend. Like the Query UI, the editor offers auto-completion for keys and values.
The Query UI can only show queries that combine conditions with AND. A query like (a="b" AND d="e") OR f="g" can only be edited with the Query Language, and the interface tells you when that's the case.

Query Examples
Key-value comparison
Keys and values can be compared using =, !=, ~, !~, =*, !=*, ~*, !~*, IN () and NOT IN ()
You can also check for the presence or absence of a certain key using IS PRESENT and IS NOT PRESENT.
Using variables and placeholders
You can use an experiment variable ({{...}}) or a template placeholder ([[...]]) as a value in a query. Markers may be written with or without quotes:
When a variable holds several values (a list of fixed values or a multi-value dynamic value), using it inside IN (...) matches any of its values:
Aggregations
To aggregate a key's value, you can use the COUNT function to check for the number of distinct values with numeric operators like <,<=,=,>= and >.
Expression Concatenation
Simple expressions can be chained with AND & OR.
Expression Negation
You can negate a specific key-value expression using NOT.
Parenthesis
Expression blocks can be encapsulated using parentheses.
Quoting Special Characters
Keys containing special characters like : and / need to be quoted to work properly.
Comments
A query can explain itself. Anything from // to the end of the line is a comment: it is ignored when the query is evaluated, and it is stored with the query, so the reason a target was excluded stays next to the exclusion.
A comment can stand on its own line:
or follow a query on the same line:
Comments work everywhere queries do — environment scopes, service target scopes, experiment blast radii, the target explorer and the API.
Two things to be aware of:
A
//inside a quoted value is part of the value, not a comment, so URLs keep working:"label.url"="https://example.com".A query made up of nothing but comments is treated as an empty query. A query only ever narrows what its scope already contains, so commenting one out stops the narrowing rather than emptying the selection: an experiment's blast radius then covers every target of that action's target type in the experiment's environment, and a service's target scope every target in its environment. The one to watch is an environment's own scope, where the query is the boundary — commenting that out covers every target in the tenant.
Last updated
Was this helpful?
