Skip to content

Commit

Permalink
feat: Allow specifying remote_write tenant in ruler_remote_write_config
Browse files Browse the repository at this point in the history
Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
  • Loading branch information
paulojmdias committed Jul 25, 2024
1 parent 2dfc13b commit 41ca5a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 6 additions & 6 deletions pkg/ruler/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,14 @@ func (r *walRegistry) getTenantConfig(tenant string) (instance.Config, error) {
clt.Headers = make(map[string]string)
}

// ensure that no variation of the X-Scope-OrgId header can be added, which might trick authentication
for k := range clt.Headers {
if strings.EqualFold(user.OrgIDHeaderName, strings.TrimSpace(k)) {
delete(clt.Headers, k)
if rwCfg.AddOrgIDHeader {
// ensure that no variation of the X-Scope-OrgId header can be added, which might trick authentication
for k := range clt.Headers {
if strings.EqualFold(user.OrgIDHeaderName, strings.TrimSpace(k)) {
delete(clt.Headers, k)
}
}
}

if rwCfg.AddOrgIDHeader {
// inject the X-Scope-OrgId header for multi-tenant metrics backends
clt.Headers[user.OrgIDHeaderName] = tenant
}
Expand Down
12 changes: 8 additions & 4 deletions pkg/ruler/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ var backCompatCfg = Config{
},
},
Headers: map[string]string{
"Base": "value",
"Base": "value",
user.OrgIDHeaderName: "org-id",
},
WriteRelabelConfigs: []*relabel.Config{
{
Expand All @@ -85,7 +86,8 @@ var backCompatCfg = Config{
},
},
Headers: map[string]string{
"Base": "value",
"Base": "value",
user.OrgIDHeaderName: "org-id",
},
WriteRelabelConfigs: []*relabel.Config{
{
Expand Down Expand Up @@ -120,7 +122,8 @@ var cfg = Config{
},
},
Headers: map[string]string{
"Base": "value",
"Base": "value",
user.OrgIDHeaderName: "org-id",
},
WriteRelabelConfigs: []*relabel.Config{
{
Expand All @@ -144,7 +147,8 @@ var cfg = Config{
},
},
Headers: map[string]string{
"Base": "value2",
"Base": "value2",
user.OrgIDHeaderName: "org-id2",
},
WriteRelabelConfigs: []*relabel.Config{
{
Expand Down

0 comments on commit 41ca5a4

Please sign in to comment.