Grafana 9.3 - usage of global variables in data source custom header

I’m trying to dynamically set values for X-Opaque-Id header in the requests sent to Elasticsearch.

In the data source configuration, I can add custom headers but how do I dynamically set the value of the header to be the login id of a user?

I tried using the global variables but they just resolve as literal strings.

${} is the ID of the current user. ${__user.login} is the login handle of the current user.



I agree but when I use ${} or ${__user.login} in a custom header of a data source, it does not resolve.

please share what you have, screen grab etc. not sure what data source you are using

Hi, this is what I mean. The data source is Elasticsearch data source.

1 Like

how do you know it resolves to literal string? are you seeing the actual traffic?

Yes, I checked what was received on the Elasticsearch end.

I would use infinity plugin instead of elastic search
it has a more robust way of sending headers.

For what it’s worth, I did find a somewhat workaround by changing the Grafana server settings to have

send_user_header = true

(default is false). If you do this, then X-Grafana-User header will be passed with the grafana user ID. (You can’t change it to another header name, it will only change this header name.). This also would do that for all data sources I believe, not just this one.

1 Like