-
Notifications
You must be signed in to change notification settings - Fork 515
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
Add mimir support with org id header #1928
Conversation
Signed-off-by: Ilya Melnikov <me@melnikov.io>
Hey @melnikovio, love this change! Out of curiosity, how are you running Mimir(on-prem vs Grafana Cloud)? What are you seeing as a response from Mimir? My only suggestion here is that we should create a separate client similar to what we do for Thanos and instantiate it only if we detect the Mimir Org ID is set. It doesn't feel correct to update all of the other clients for a Mimir specific implementation detail. |
Thank you @Pokom!
At the first time I made a separate client. But it will literally differ by exactly one line with the Header. And I thought it was redundant. If you think new client is better - I'll change it. |
@Pokom https://cortexmetrics.io/docs/guides/auth/ What difference does it make whether it is a cloud installation or a local one. To work with multi-tenancy, you need to pass a header. If you don't like the implementation with a separate Mimir client, let's globally add the ability to add headers to all clients. Let the backend decide whether it needs this header or not. |
I agree with @Pokom, it seems that exposing X-Scope-OrgID with the default for Prometheus and letting different implementations override it seems straightforward. Kubecost uses Thanos, so they probably have opinions too. @AjayTripathy want to weigh in? |
@Pokom , @mattray for those who also need the
and use this prometheus address PROMETHEUS_SERVER_ENDPOINT=http://127.0.0.1:9091/prometheus I would like to do it without workarounds |
pkg/costmodel/router.go
Outdated
@@ -1535,6 +1535,7 @@ func Initialize(additionalConfigWatchers ...*watcher.ConfigMapWatcher) *Accesses | |||
}, | |||
QueryConcurrency: queryConcurrency, | |||
QueryLogFile: "", | |||
MimirHeaderOrgId: env.GetMimirHeaderOrgId(), |
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.
Could we just rename this field to something like xScopeOrgIDHeader to make it a bit more generic, especially if its not specific to Mimir?
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.
Done
pkg/env/costmodelenv.go
Outdated
@@ -92,6 +92,8 @@ const ( | |||
PrometheusRetryOnRateLimitMaxRetriesEnvVar = "PROMETHEUS_RETRY_ON_RATE_LIMIT_MAX_RETRIES" | |||
PrometheusRetryOnRateLimitDefaultWaitEnvVar = "PROMETHEUS_RETRY_ON_RATE_LIMIT_DEFAULT_WAIT" | |||
|
|||
MimirHeaderOrgIdEnvVar = "MIMIR_HEADER_ORG_ID" |
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.
Same with making this generic?
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.
Done. Now variable is: PROMETHEUS_HEADER_X_SCOPE_ORGID
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.
Sorry for the late responses here @melnikovio -- I would support this change would just want to make this generic so you can pass any X-SCOPE-ORG-ID header. That seem like a fair compromise?
Signed-off-by: ilya.melnikov <ilya.melnikov@idp.zyfra.com>
Signed-off-by: ilya.melnikov <ilya.melnikov@idp.zyfra.com>
Signed-off-by: ilya.melnikov <ilya.melnikov@idp.zyfra.com>
@AjayTripathy pls review pr |
Can this be reviewed @AjayTripathy ? We are also wanting to use opencost with Mimir (self hosted). |
Hi @AjayTripathy , I hope this message finds you well. I noticed this pull request and was wondering about its status. In our project, we are also in need of mimir support. |
@cliffcolvin can we get this reviewed by the core team? |
The changes were made, and he asked for someone else to review.
What does this PR change?
Add required by Mimir header X-Scope-OrgID in http Prometheus client.
To use Mimir instead of Prometheus add variable:
"PROMETHEUS_HEADER_X_SCOPE_ORGID": "my-cluster-name"
Then set Prometheus URL to Mimir endpoint:
"PROMETHEUS_SERVER_ENDPOINT": "http://mimir-url/prometheus/"
Does this PR relate to any other PRs?
No
How will this PR impact users?
Adds ability to use Mimir storage instead of Prometheus
Does this PR address any GitHub or Zendesk issues?
No
How was this PR tested?
Manual
Does this PR require changes to documentation?
Yes
Have you labeled this PR and its corresponding Issue as "next release" if it should be part of the next Opencost release? If not, why not?
Required release