Variable regex with forward slash

I have a dashboard variable called “filename”, which looks like

  bucket: v.bucket,
  tag: "ff",
  predicate: (r) => true,
  start: -1d

It gives me values of the key for “ff”.
The values look like: /tmp/a/b, /sbin, /etc/cron

So my grafana query look like

filter(fn:(r) => r["ff"]=~ /^${filename:pipe}$/)

i keep getting invalid: compilation failed

Do any of these work?

|> filter(fn: (r) => r["ff"] == "${filename}")


|> filter(fn: (r) => r["ff"] =~ /${filename:regex}/)


 |> filter(fn: (r) => r["ff"] =~ /^${filename:regex}$/ )
1 Like

You need to ecape regular expression metacharacters in your variable, so valid regexp will be generated:

I really appreciate it. Thanks a lot

Which expression worked (if any)?