Variable interpolation in data source custom http headers

  • What Grafana version and what operating system are you using?
    10.0.2 + CentOS 7

  • What are you trying to achieve + How?
    As a user, I need to limit data source access based on the logged in user. This is easily achieved by setting a custom header on the elasticsearch data source with the key of es-security-runas-user. Ideally we’d be able to set this header based on the ${__user.login} variable as that contains the logged in user name.

  • What happened?
    When setting the header to the variable, the literal string is returned and the variable is not interpolated. This results in an access denied message when trying to connect to the data source.

  • What did you expect to happen?
    Ideally, when setting the variable in the header it would be interpolated and expanded out to the currently logged in user.

I acknowledge there are likely some security concerns around arbitrary variable interpolation into a header but the folks with data source management permissions can probably get most of those values already. Another option may be a toggle to enable just this header.

Based/referenced from Grafana 9.3 - usage of global variables in data source custom header