6

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 ?

user1972670
  • 397
  • 1
  • 4
  • 15

1 Answers1

4

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}

Tobias D
  • 345
  • 2
  • 12