KB-2684
KB-2684

Reputation: 31

Get current user details from Grafana dashboard

Can anybody help me to get current logged in user's details(at-least email) from Grafana dashboard. I am creating custom panel plugin in Grafana and required the user details. Please help!

Upvotes: 1

Views: 1579

Answers (3)

Timay
Timay

Reputation: 88

You can get it from the grafana runtime lib.

import { config } from '@grafana/runtime';

console.log(config.bootData.user);

Upvotes: 1

KB-2684
KB-2684

Reputation: 31

I found the solution, this may help someone else. You just need to import config from app/core and you will get user details under

config.bootData.user

like this:

import config from '../../../../public/app/core/config';
interface Props extends PanelProps<SimpleOptions> {}
console.log(config.bootData.user)

Upvotes: 0

Jan Garaj
Jan Garaj

Reputation: 28656

You can call Grafana API GET /api/user - API doc.

Upvotes: -1

Related Questions