How to get user in a Custom Panel Plugin?

Hi ,

Is it possible to get user information in a custom panel plugin ? Retrieving a userId will be sufficient for me .

Thank you in advance

2 Likes

If I understand, It’s possibile using Grafana API

This should be a possible piece of your code:

this.backendSrv.get('/api/users')
    .then((result) => {
       user_infos = _.filter(result, {"name": "my_user"});
    });

where “my_user” could be the username you are looking for information.
(code not tested and incomplete)

1 Like

I’m assuming @rernas is looking for the ID/info of the currently logged in user (who’s viewing the plugin), rather than an arbitrary user with a known username. I’d be interested in knowing the answer to that question also.

So maybe this is useful:

2 Likes