Query Language
Last updated
Last updated
There are some use cases, where you want to restrict the targets discovered by Steadybit. One use case can be that you want to design an experiment and make sure, that there are only targets of a specific Kubernetes cluster affected by the experiment. Another use case is that you want to restrict the available targets when configuring an environment.
Boiling down to a set of targets can result in complex statements. For instance, you want to make sure that the targets are matching some sets of key-value pairs but also not in your production cluster. Expressions like these can now easily be written in Steadybits Query Language. The Query Language is a textual representation of the Query UI but with a more advanced feature set. It allows you to build semantic expression blocks, combining them with other expressions or negating them. The Query UI and the Query Language always come together, so it is up to you to choose the style.
When introducing the Query Language, we added a new tab to the already known query UI. Clicking it will switch the edit mode to the Query Language. The already configured query will be translated into the textual form and rendered within the text editor. You can just go ahead writing your own query expressions in there. Like the Query UI, the editor will provide you with auto-completion on available keys and values.
Please note that the Query UI is limited in regard to the queries you write. For instance, one cannot express a query like (a="b" AND d="e") OR f="g"
with the Query UI. The interface will tell you when the query can only be edited with the language editor.
Keys and values can be compared using =
, !=
, ~
, !~
, =*
, !=*
, ~*
, and !~*
.
You can also check for the presence or absence of a certain key using IS PRESENT
and IS NOT PRESENT
.
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 >
.
Simple expressions can be chained with AND & OR.
You can negate a specific key-value expression using NOT.
Expression blocks can be encapsulated using parenthesis.
Keys containing special characters like :
and /
needs to be quoted to work properly.