[LogQL] Optional variables for stream selectors or filters

What Grafana version and what operating system are you using?

Grafana v10.1.5 (849c612fcb)

What are you trying to achieve?

I’m setting up dashboard to let developers access Traefik logs (stored on Loki and queried with . I’m preparing some variables that they can use to filter data.

I can use regular expression defaulting to .* to match any for some. However, I’ve some variables that are used as prefix or infix:

  • ${prefix_variable}-.*
  • .*-${infix_variable}-.*

The wildcard don’t work as it still enforce the label/field contains the static characters (e.g. separator, static prefix)

How are you trying to achieve it?

I don’t see how to build (and if this possible) the log stream selector part with given constraints.

What happened?

N/A

What did you expect to happen?

Being able to query with optional variables/label selectors

Can you copy/paste the configuration(s) that you are having problems with?

N/A

Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

N/A

Did you follow any online instructions? If so, what is the URL?

No.