Skip to content
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

Support for X-Scope-OrgID header in Prometheus scaler #2667

Closed
romanvog opened this issue Feb 24, 2022 · 9 comments · Fixed by #2763 or kedacore/keda-docs#714
Closed

Support for X-Scope-OrgID header in Prometheus scaler #2667

romanvog opened this issue Feb 24, 2022 · 9 comments · Fixed by #2763 or kedacore/keda-docs#714
Assignees
Labels
enhancement New feature or request feature-request All issues for new features that have not been committed to good first issue Good for newcomers prometheus

Comments

@romanvog
Copy link

Proposal

Need to add support for X-Scope-OrgID header as part of the query to a multi tenant cortex (prometheus metrics), since it's not possible to get a response without it when multi tenancy is enabled.

Use-Case

We're using scalers from type prometheus, and recently moved to a multi tenant cortex to serve metrics from multiple different prometheus instances in different clusters. To support multi tenancy, we need to provide X-Scope-OrgID header for cortex to know which prometheus data to return.
We need to pass this header in keda's prometheus scaler as well if we want to use cortex endpoint (which we do).

Anything else?

No response

@romanvog romanvog added feature-request All issues for new features that have not been committed to needs-discussion labels Feb 24, 2022
@tomkerkhove tomkerkhove moved this to Proposed in Roadmap - KEDA Core Feb 24, 2022
@JorTurFer JorTurFer moved this from Proposed to To Do in Roadmap - KEDA Core Feb 24, 2022
@JorTurFer
Copy link
Member

Hi @romanvog
This sounds totally reasonable 😄
Are you willing to contribute?

@JorTurFer JorTurFer added prometheus enhancement New feature or request good first issue Good for newcomers and removed needs-discussion labels Feb 24, 2022
@romanvog
Copy link
Author

hey @JorTurFer,
not familiar with go, but i can give it a try :)
want to point me to the place in code where prometheus type is implemented?

@JorTurFer
Copy link
Member

Hey!
This is the scaler code

@JorTurFer JorTurFer moved this from To Do to In Progress in Roadmap - KEDA Core Mar 15, 2022
@xoanmm
Copy link
Contributor

xoanmm commented Mar 15, 2022

I would like to tackle this 😄

@JorTurFer
Copy link
Member

Thanks a lot! ❤️

@zroubalik zroubalik moved this from In Progress to In Review in Roadmap - KEDA Core Mar 16, 2022
Repository owner moved this from In Review to Ready To Ship in Roadmap - KEDA Core Mar 16, 2022
@aberenshtein
Copy link

aberenshtein commented May 9, 2022

@JorTurFer @xoanmm
I'm trying to test it with keda 2.7.0
This is my keda scaledObject

 triggers:
    - metadata:
        cortexOrgId: saas-stg
        metricName: bull_queue_houzz1_waiting
        query: >-
          bull_queue_houzz1_delayed{queue="email"} +
          bull_queue_houzz1_waiting{queue="email"}
        serverAddress: http://<our cortex server>/prometheus
        threshold: '1'
      type: prometheus

And I get this error

2022-05-09T11:02:59+03:00 1.6520833799251316e+09	ERROR	scalehandler	Error getting scale decision	{"scaledobject.Name": "ivy-worker-email", "scaledObject.Namespace": "houzz1", "scaleTarget.Name": "ivy-worker-email", "error": "prometheus query api returned error. status: 401 response: no org id\n"}

If I make a direct query to http://<our cortex server>/prometheus?query=<query from above>
and I add the X-Scope-OrgID header I get a 200 response

If I remove the header, I'm able to reproduce the issue from above.

What am I doing wrong? It seems the header is not added properly

@aberenshtein
Copy link

https://github.com/kedacore/keda/blob/main/pkg/scalers/prometheus_scaler.go#L197
Maybe this should be

if s.metadata.cortexOrgID != nil {
		req.Header.Add(promCortexHeaderKey, s.metadata.cortexOrgID)
	}

@JorTurFer
Copy link
Member

Hey,
Could you open another issue with this bug? Just to track it better 🙏

@aberenshtein
Copy link

Sure. #3024
Can you add a bug label to my issue please

@tomkerkhove tomkerkhove moved this from Ready To Ship to Done in Roadmap - KEDA Core Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature-request All issues for new features that have not been committed to good first issue Good for newcomers prometheus
Projects
Archived in project
4 participants