user1972670
user1972670

Reputation: 397

Grafana user variables

is it possible to use Grafana's userID or user variables in MySQL query ?

For example :

SELECT id,name FROM table WHERE user_id=$Grafana.User.id

Or is there another way to assign a custom variable to specific user within Grafana ?

Upvotes: 6

Views: 2106

Answers (1)

Tobias D
Tobias D

Reputation: 375

It is available in Grafana 7.1+ as ${__user.id}. Check the doc: https://grafana.com/docs/grafana/latest/variables/variable-types/global-variables/ This should work:

SELECT id,name FROM table WHERE user_id=${__user.id}

Upvotes: 4

Related Questions