Rate limit sessions for throttling control #36
Merged
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.
When using service identity authentication in datasource, query requests originating from different users share the same identity, and may be seen my the resource endpoint as coming from the same user.
I may occasionally trigger throttling problems in large Grafana instances with popular dashboards.
This PR introduces an additional session header
X-RateLimit-Session
, different for each Grafana user, which provide extra information to the resource endpoint regarding the different user sessions which share the same service identity for authentication.This session header needs to be enabled by the datasource:
To make sessions work, datasource should also include context of the signed-in user to the request context, as implemented in the ADX datasource here or here. This allows the Azure middleware to use the passed user's information to generate session ID.
Resource endpoint should know about the header and use it for its rate limit calculations.