Grafana

Usage

Grafana with Loki can be a bit of a hassle when it comes to creating queries for the panel. I wanted a panel where I could select on either job or container from two variables like this.

This is what came to mind from the beginning this essentially means regexp match moth the job and container label to their corresponding variables if no value or All is selected include everything.

ShellScript
{job=~"${job:.*}|.", container=~"${container:.*}|."}

Unfortunately Grafana complains about this since it is not allowed two matchers that matches everything (Probably it is two avoid matching the whole dataset at once).

It is however possible to do this, which translates to that job must always be set, but container can be All. This works OK since all logs matching the container variable also has the job label docker.

{job=~"${job:.*}|.*", container=~"${container:.*}|.*"}

Leave a Comment

Your email address will not be published. Required fields are marked *