Grafana user variables
Asked Answered
C

1

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 ?

Chiaroscuro answered 19/5, 2019 at 8:31 Comment(2)
what's your question .. you have error ?? show th error message ..Oceania
I'm trying to pass in Grafana's user ID to the query. Is there a variable that can give me loggedin user ID from GrafanaChiaroscuro
A
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}

Accursed answered 28/9, 2020 at 13:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.