Can I include a variable with topk?

Hello, using the Luster exporter, I’m trying to show the top 20 lustre_bytes_read_total and lustre_bytes_write_total, using topk. As I have two file systems (FS) in my Luster environment, I would like to build a dynamic panel so that I can chose one FS or the other, getting the top 20 for either.

Hence I first created a variable which returns the two FS options that correctly return my FS options (using regex). I then wrote the query:
topk(20, lustre_read_bytes_total{target=~"$targ"}) However this returns “no data”.

My query inspector reveals : expr:“topk(20, lustre_read_bytes_total{target=~“scratch1”})” , scratch1 is the FS I chose in my variable drop-down.

In Prometheus, if I look only at (20, lustre_read_bytes_total), I see data such as:
lustre_read_bytes_total{component=“client”, instance="", job=“Lustre”, target=“scratch1-ffff92b0ded99800”}

Why am I not able to use the defined variable in my query?

Thanks.

I figured out what the problem was. My variable needs to be a chained variable to result in a successful query. Now the only problem I have is that when I select one FS target, I get good data, but with variable selecting the other FS, my query times out (no error, tho!) and I get no data. A raw Prometheus query of lustre_read_bytes_total returns 32717 entries pretty quickly in Prometheus, slower in Graf, but I guess that’s because of the chained variables. If one variable works, seems like the other variable should, too. I’ll keep trying. . . .