Restrict user to variables

I am using Grafana OSS 9.2.3. I want to build a dashboard with dropdown variable on the top. This dashboard can generate graphs from different systems and I would control which system to see using the variables.

I am looking for a way to restrict users to only have access to their data, by restricting which values they can see in the dropdown.
I checked on the user screen if I can do anything like that, but it was not obvious.

I was also thinking about storing the user-variable mapping in a table, and use the query behind the variable to pick which values the user can select. Is that a solution that you would recommend? Can I put the current userid into the query as a parameter?

Thanks a lot for suggestions.
Csongor

@yosiasz Thanks a lot, I have to give it a try. I wonder if it would be easier to create a simple CSV file that maps the users to the variables. That would be easier to maintain than a influx measurement (I don’t have a separate SQL server in my setup). I can probably set up a data source for a simple CSV file.

You could dobfhat in csv as well. But seems like a very brittle solution and unsustainable?

I looked for other suitable data sources and I found a JSON datasource: JSON plugin for Grafana | Grafana Labs

I am trying to put a query together in which I pass the current user in the payload, so I can get some value back that I can use as variables.

But I can’t figure out how to pass username as a global variable. The article you linked above shows @username, this page says ${user.login}, but nothing appears to be accepted.
Maybe I cannot use a global variable in the payload section?

Yes I know, I was looking at the same document, but it does not seem to work. If you check the screenshot below, in the raw query the payload is empty:

1 Like

Is that really a node red plugin? What is the data sourxe for that?

It a JSON data source. But I am planning to pick up the request in Node-Red and generate a data structure that is accepted by Grafana.

1 Like