"Mapping" logged in users with data in the external database

Hello all,
We have some specific requirements, and I don’t know if it is really possible, and if is, how.

Here is the scenario, based on Grafana on sqlite3 database.

  • we have Grafana users defined in Grafana\Users, and we can search for them in the Grafana sqlite3 database
  • the same users are defined in the external database, in “username” columns

What we want to achieve:

  • we want to “pair” logged in user - Grafana should look for its username - with the same username in the external database - we can access to that database in the Dashboard", aand with that “pairing”, users should be able to see only data which is relevant to his username.
    We want to avoid any hardcoding. In the real time, Grafana should recognize currently logged in user and “pair” data with the user’s username in external database, and then show only relevant data for his user.

I’m not sure if I explained it well.

Thanks in advance.

Here are the global variables related to currently logged in user

${__user.email} Email for the current user.
${__user.id} Id of the current user.
${__user.login} Login handle of the current user.