Display data according to user name

Hello everyone,
I have dashboards that monitor servers and they are divided into groups according to the departments I created and each department has a username that corresponds to its name.
The servers are filtered using regex so that each department has its own servers
I want each department to be shown its server table only and not all the tables of all departments.
I tried using the global variable “${__user.login}” but without success.
I would appreciate your help

Hi @alonagag,

Welcome to the :grafana: community support forums !!

What is your Datasource that you are using and also want to monitor it per username?

I am using prometheus Datasource

Thanks. Can you please share the screenshot of the query editor where you are writing the query to get the data?

I have a variable called group that contain all the departments.
I want for example that the user SDT will only see his data.
A query for example:

I have researched this a bit but originally could not found a way (PromQL) which allows the active users to be monitored and then display data based on it.

However, I found that there is a 3rd party script Active Users Exporter for Prometheus which is like a Node-Exporter but for users.

Maybe you want to check that out it that fits your case.

Also, someone from the community might know this from previous case and might be able to give more help

So users login into grafana using their pre-defined department “username” ?

1 Like

Yes, exactly
Yes, exactly

most unusual approach but it works! In that case, I assume you will get rid of that drop down?

So are those department names also embedded in your prometheus data?

Have you looked at

Those department names are not embedded in my Prometheus data, but all the server names are, and with the help of the group variable I divide them into departments.

I read the article that you sent to me, but I dont know how I can use this global variable:${__user.login}
in a query… do you have any idea?

just like you used it in your prom query


assuming ${__user.login} is identical to one of your Groups: SDT, DEVOPS. VBU etc


but there are queries that using the group name like “SDT” ,and there are queries that using the group value like:“(?i)(dts|SDTCCMANUAL1|syr|SDTAEPR).*”
and this takes all the SDT servers.

How I can combine both of them together? I mean the group value and the user login.