-
Notifications
You must be signed in to change notification settings - Fork 818
Introduce a regex tenant resolver #6713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Introduce a regex tenant resolver #6713
Conversation
1b8963e
to
e6a4222
Compare
@CharlieTLe |
e6a4222
to
63f97d2
Compare
// because if the # of matched tenantIDs is only one, `X-Scope-OrgID` header is | ||
// set to input regex. | ||
byPassForSingleQuerier = false | ||
tenant.WithDefaultResolver(tenantfederation.NewRegexResolver(prometheus.DefaultRegisterer, t.Cfg.TenantFederation.UserSyncInterval, util_log.Logger, t.Distributor.AllUserStats)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there is a better way to gather all users. Calling t.Distributor.AllUserStats
seems a bit expensive just to get user IDs.
And it cannot cover users that don't ingest anymore but maybe their data still present on long term storage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And it cannot cover users that don't ingest anymore but maybe their data still present on long term storage.
Thanks for catching.
How about utilizing the userScanner
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling t.Distributor.AllUserStats seems a bit expensive just to get user IDs.
Do you have any good ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome!
Signed-off-by: SungJin1212 <tjdwls1201@gmail.com>
63f97d2
to
605f91a
Compare
This PR introduces a regex tenant resolver to allow regex in the
X-Scope-OrgID
value when the user usestenant-federation
feature.It introduces two flags,
tenant-federation.regex-matcher-enabled
andtenant-federation.user-sync-interval
.tenant-federation.regex-matcher-enabled
enables the regex resolver, which allows regex to theX-Scope-OrgID
value.tenant-federation.user-sync-interval
specifies how frequently to scan users. The scanned users are used to calculate matched tenantIDs.The regex matching rule follows the Prometheus regex matcher (
=~
), See here.For example, if there are 3 tenants, whose IDs are
user-1
,user-2
, anduser-3
. We can setX-Scope-OrgID
touser-.+
to query whole tenants.Also, we can use an existing way like setting
user-1|user-2|user-3
toX-Scope-OrgID
.Which issue(s) this PR fixes:
Fixes #6588
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]