🔥 Real-World Examples: Explore Our Salesforce & ManoMano Case Studies! 🔥 Read Now

Blog

Use Steadybit's Query Language to enhance your experiments

Use Steadybit's Query Language to enhance your experiments

Behind the Scenes
30.09.2022 Simon Thiele - 5 min read

When managing complex environments it’s important to have powerful tools available to keep control. Now, Steadybit enhances the way how to filter targets by introducing the Query Language.

Status Quo

When running experiments, it is crucial that you can boil down to a set of targets you want to run your experiment on. Targets are discovered by the Steadybit agent and will then be available for your experiments on your Steadybit platform. The landscape already gives you a good overview of known targets, yet it is limited by Kubernetes deployments.

Steadybit’s landscape map – Deployment targets clustered by namespace

So, there are even more targets that you can use to plan your experiments around. Hosts, containers, networks, AWS zones, everything can be targeted when creating an experiment. To do so, Steadybit provides you with all information extracted for the discovery process. This information (attributes) can be used as key-value pairs to build a query that filters down all targets available to a set of targets you want to focus on. Steadybit’s UI gives you an excellent visual representation of the query, giving you a good overview of available attributes and the overall query you are about to express.

Steadybit’s experiment designer – targets can be boiled down using the Query UI or the Query Language

Unleash the Full Target Selection Potential

As noted in the section above, key-value pairs are essential to filter your targets and make sure experiments are executed against the right set of hosts, deployments, clusters etc.

Sometimes, there are even more advanced use-cases where the regular query UI reaches its limits:

  • Quickly share a query with your peers via copy-paste.
    • Sometimes, you just want to copy a query and paste it into a knowledge base, or use it for some other experiment, or dump it on Slack, or…
  • Writing expressions where multiple key-value pairs are chained with an OR.
    • Sometimes, you want to write queries which are matching either a given cluster name or a namespace for instance. Queries like that can be very powerful and provide maximum flexibility expressing your needs.
  • Building blocks of expressions with parentheses.
    • For even more complex queries, you sometimes need to build logical blocks wrapped by parenthesis like when you’re building other logical expressions in your code for example.
  • Negating expressions.
    • A special case, where you want to exclude a specific set of targets, for instance everything running in your production cluster.

Meet the Query Language

To support all the mentioned use-cases we are now excited to present you Steadybits query language as an extension to the already existing query UI. The query language is a textual representation of the query you’ve composed through the UI. While the query UI can be used to cover simple cases and to have an easy onboarding, the query language now unlocks the full potential of writing expressions, grouping them into logical blocks and chaining them through multiple operators. The query UI and the query language always work together, so it is up to you to choose the style. You can switch from one representation to the other and back again as you like.

The same query expressed with the Query UI on the left and the Query Language on the right

Meet the Query Language

The embedded text editor can now be used to implement the use cases noted in the upper sections. Let’s do it by example:

  • Quickly share a query with your peers via copy-paste. Since there is now a regular text editor, go ahead and copy your query.
  • Writing expressions where multiple key-value pairs are chained with an OR. You can use AND & OR to chain your expressions like: k8s.cluster-name="prod" OR k8s.cluster-name="staging"
  • Building blocks of expressions with parentheses. Just go ahead, scope your expressions like: (k8s.cluster-name="prod" OR k8s.cluster-name="staging") AND (k8s.namespace="team-A" OR k8s.namespace="team-B")
  • Negating expressions: Nothing easier than that: NOT k8s.cluster-name="prod"

Visit our docs for further information ✌🏼

There is nothing better than putting what you have learned directly into action. Sign up directly in Steadybit via our free plan and experience the full potential.