Access User information that is using the plugin

Hello there.

I am developing a plugin for grafana that sends messages to a backend and I want to add user information to the request (which normally is the ${__user.login} global variable) The thing is, I can’t find where this would fall. I tried searching the TemplateSrv in the @grafana/data but it seems it’s only for dashboard defined variables. Is there a way to access this information inside a plugin?

Also it seems that setting a variable with the content of a global variable is not working. I tried creating a dashboard variable of type custom/constant and the content would be the above mentioned global variable but it doesn’t get the data.

If it helps, I am using Grafana 7.0.0

Thanks in advance

1 Like


Does the user need to be able to supply in their templates, or would it be sufficient if the plugin could extract it from their request without them explicitly passing the information?

Also, what type of plugin are you building? User information is exposed differently depending on if it’s a data source plugin or backend plugin for example.

Hi Marcusolsson and thank you for your reply.

We are building a Panel plugin and we do not want the user to explicit pass the information. We would like our panel to get the user login (or the user information object).

Hm. I’m not sure whether user information is exposed to panel plugins through the SDK.

I haven’t tried it myself, but I think you could also access the logged in used by calling /api/user using BackendSrv:


Thank you for your quick reply. I will try this approach until the end of the week and will give feedback asap.

We have an older panel developed in Angular that we were trying to upgrade to React. In that panel we could access this information by using:


Nonetheless, i will try this method and report asap to see if we can close this issue. Thanks again

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.