query-frontend: Log X-Grafana-User header in query stats - #7799
Open
yeya24 wants to merge 1 commit into
Open
Conversation
When Grafana's [dataproxy] send_user_header is enabled, Grafana adds an X-Grafana-User header with the logged-in username to all data source proxy requests. This commit logs this header in the query frontend's query stats, slow query, and query request log messages, making it easier to attribute queries to specific Grafana users. The header is already logged alongside X-Dashboard-Uid and X-Panel-Id in the formatGrafanaStatsFields helper, so it appears in all three logging paths automatically. Signed-off-by: Ben Ye <benye@amazon.com>
SungJin1212
reviewed
Aug 21, 2026
| # Changelog | ||
|
|
||
| ## master / unreleased | ||
| * [ENHANCEMENT] Query Frontend: Log `X-Grafana-User` header in query stats, slow query, and query request logs when Grafana's `send_user_header` is enabled. #7797 |
Member
There was a problem hiding this comment.
LGTM, Can you fix a changelog? (order and pr number)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
When Grafana's
[dataproxy] send_user_headeris enabled (grafana/grafana#15998), Grafana adds anX-Grafana-Userheader with the logged-in username to all data source proxy requests.This commit logs this header in the query frontend's query stats, slow query, and query request log messages, making it easier to attribute queries to specific Grafana users.
The header is logged alongside the existing
X-Dashboard-UidandX-Panel-Idin theformatGrafanaStatsFieldshelper, so it appears in all three logging paths automatically.How to enable
On the Grafana side, set:
No Cortex-side configuration change is needed — the header is logged whenever it's present in the request.
Checklist
CHANGELOG.mdupdated