# Can I access variable value as access control?(Limit users to access Variable values)

**URL:** <https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729>\
**Category:** Configuration\
**Tags:** dashboard-variables, grafana-roles, grafana\
**Created:** [January 20, 2025, 7:10am UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729 "2025-01-20T07:10:29Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![chethan4046](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@chethan4046](https://community.grafana.com/u/chethan4046)\
**Post date:** [January 20, 2025, 7:10am UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/1 "2025-01-20T07:10:29Z")

</div>

I have created a dashboard with a dropdown variable that lists my server names. For example, these servers belong to individual IT persons. I want to give access to users based on the server name (list). For instance, if I am the owner of Server A, I need to assign access to a specific variable value A so that the respective IT personnel can view only the dashboard for Server A.

**Note:** Based on the variable, this dashboard fetches node metrics from the respective servers.

 ![Screenshot 2025-01-20 at 12.38.49 PM](https://us1.discourse-cdn.com/grafana/original/3X/c/f/cf296c80af20b35ad76302f5037e020041e413e1.png)

---

<div class="post-metadata">

**Author:** ![jangaraj](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jangaraj/32/39197_2.png) [@jangaraj](https://community.grafana.com/u/jangaraj)\
**Post date:** [January 20, 2025, 8:14am UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/2 "2025-01-20T08:14:59Z")

</div>

It depends.

For example you can use LBAC to define datasources and then RBAC to define access to those datasources

> **[Using label-based access control (LBAC) | Grafana Enterprise Metrics...](https://grafana.com/docs/enterprise-metrics/latest/tenant-management/lbac/)**
>
> Overview Label-based access control can be used to create access policies that will only allow for data to be queried that meets specific label requirements. The feature allows multiple sets of Prometheus label selectors to be associated with a...

> **[Grafana Role-based access control (RBAC) | Grafana documentation](https://grafana.com/docs/grafana/latest/administration/roles-and-permissions/access-control/)**
>
> Role-based access control (RBAC) provides a standardized way of granting, changing, and revoking access so that users can view and modify Grafana resources, such as users and reports.

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [January 20, 2025, 12:49pm UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/4 "2025-01-20T12:49:28Z")

</div>

Where is this IT person to server relationship saved

---

<div class="post-metadata">

**Author:** ![chethan4046](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@chethan4046](https://community.grafana.com/u/chethan4046)\
**Post date:** [January 20, 2025, 12:54pm UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/5 "2025-01-20T12:54:06Z")

</div>

@yosiasz Based on the AD group or user, we need to select which AD groups or users should have access to specific servers

---

<div class="post-metadata">

**Author:** ![chethan4046](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@chethan4046](https://community.grafana.com/u/chethan4046)\
**Post date:** [January 20, 2025, 12:55pm UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/6 "2025-01-20T12:55:46Z")

</div>

@jangaraj Thank you for your response. Let me go through it and get back to you.

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [January 20, 2025, 12:58pm UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/7 "2025-01-20T12:58:14Z")

</div>

So how is an ad group or user associated with one or many server(s)

Where is that relationship saved at, within as or elsewhere

---

<div class="post-metadata">

**Author:** ![chethan4046](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@chethan4046](https://community.grafana.com/u/chethan4046)\
**Post date:** [January 20, 2025, 3:21pm UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/8 "2025-01-20T15:21:49Z")

</div>

Nowhere as of now, but I am planning to use variable values so that if a variable value matches a specific user, I need to give access to a specific panel

For example, if the variable name “serviceName” has values A, B, C, and D, I need to assign user A to the variable name value A.  
so that when A users login to grafana it A value will be selected in variable and give A value specific pannel

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [January 20, 2025, 3:40pm UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/9 "2025-01-20T15:40:59Z")

</div>

here are some things you can take a look at and I think you referenced the below post in slack channel

> [@Limit users to access Variable values](https://community.grafana.com/t/limit-users-to-access-variable-values/8513/13):
>
> It looks like that variable does exist based on the above here is an example with sample ddl & dml use grafana --this is my own ms sql server database --for testing things out not grafana's db go drop table companies create table companies(companyid int identity(1,1), companyname varchar(50) ) insert into companies select 'Acme' union select 'Zimza' drop table users; create table users(username varchar(50)) insert into users select 'ddenson' drop table usercompanies create table …

---

<div class="post-metadata">

**Author:** ![chethan4046](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@chethan4046](https://community.grafana.com/u/chethan4046)\
**Post date:** [January 21, 2025, 8:14am UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/10 "2025-01-21T08:14:31Z")

</div>

@yosiasz Yes. I have come across this blog, But I need to use azure AD as sso

---

<div class="post-metadata">

**Author:** ![jangaraj](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jangaraj/32/39197_2.png) [@jangaraj](https://community.grafana.com/u/jangaraj)\
**Post date:** [January 21, 2025, 9:05am UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/11 "2025-01-21T09:05:31Z")

</div>

Use Grafana SAML SSO against Azure AD with team sync - users will have assigned Grafana teams based on user groups in AD. Each team will have own RBAC custom role with query permissions for LBAC based datasources.

---

<div class="post-metadata">

**Author:** ![chethan4046](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@chethan4046](https://community.grafana.com/u/chethan4046)\
**Post date:** [January 21, 2025, 2:38pm UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/12 "2025-01-21T14:38:54Z")

</div>

@jangaraj Can I have some examples of documents?  
I have only one data source

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [January 21, 2025, 2:41pm UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/13 "2025-01-21T14:41:44Z")

</div>

Are we talking about `sso` for authentication purposes or are we talking about associating servers with users?

---

<div class="post-metadata">

**Author:** ![chethan4046](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@chethan4046](https://community.grafana.com/u/chethan4046)\
**Post date:** [January 21, 2025, 2:46pm UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/14 "2025-01-21T14:46:28Z")

</div>

I am talking about associating servers with users.  
Ex: I am the owner of server A., I will log in to Grafana using Azure Ad, I should able to access only A value in the variable so I will get access to A value specific pannel

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [January 21, 2025, 3:15pm UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/15 "2025-01-21T15:15:44Z")

</div>

> [@chethan4046](#):
>
> Ex: I am the owner of server A., I will log in to Grafana using Azure Ad, I should able to access only A value in the variable so I will get access to A value specific pannel

yep, I think we have already established that 😁

create and populate tables `servers(server_id, server_name)` and a bridge table called `user_servers(server_id, mail varchar(150))`

Then a query of the tables

```auto
select s.server_name as dropdown
 from servers s
join user_servers us on s.server_id = us.server_id
where us.mail = ${__user.email} -- < currently logged in user

```

---

<div class="post-metadata">

**Author:** ![chethan4046](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@chethan4046](https://community.grafana.com/u/chethan4046)\
**Post date:** [January 21, 2025, 3:41pm UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/16 "2025-01-21T15:41:41Z")

</div>

How can I connect with you @jangaraj,  
I am using Amazon-managed-grafana  
I don’t think that is possible, We can’t create table.

---

<div class="post-metadata">

**Author:** ![jangaraj](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jangaraj/32/39197_2.png) [@jangaraj](https://community.grafana.com/u/jangaraj)\
**Post date:** [January 21, 2025, 4:11pm UTC](https://community.grafana.com/t/can-i-access-variable-value-as-access-control-limit-users-to-access-variable-values/140729/17 "2025-01-21T16:11:05Z")

</div>

Sorry, this is not a private support, but public community forum.

If you need a private support session, then I recommend to pay for a Grafana support. Actually, you can connect to your AWS support, because they support your instance.
