SMA
SMA

Reputation: 377

Exclude some variables in Grafana

I have a grafana dashboard that have a variable namespace, my datasource is Loki. I use this query to get list of namespaces: label_values(namespace), it works well and results are like name1, name2, name3, name4, ..., nameN . but in my dashboard I don't want to see name2 and name4, is there anyway to exclude this 2 name from variable list?

Upvotes: 0

Views: 2481

Answers (1)

markalex
markalex

Reputation: 13421

You can filter variables with regex.

In your case regex will look like this:

/^(?!(?:name2|name4)$)(.+)/

Demo and details for that regex can be seen here.

In short, this is a regex that matches (and captures into group #1) anything (.+), unless beginning of the string is immediately followed by one of name2 or name4 and end of string after that.

More details on matching everything except something specific here.

Upvotes: 2

Related Questions