-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Metrics API Scaler support different format #2633
Comments
|
oh right, yes new field would definitely better |
Based on #2644 OpenMetrics is a very good idea for another format |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
Any plans on this? |
No, are you willing to contribute this? |
Nope. Sorry. I don't. have the skill 😞 |
No worries! |
hello guys , I am a new joiner which want to contribute to Keda and have read the contribute guide. I want to contribute on this issue. Could you give me some guide about this issue |
@JorTurFer @zroubalik Can you help @LuckyDogg? Would be a nice addition |
Hey, sure 😄 Basically you need to add the needed changes in the scaler code, and cover it with [tests](https://github.com/kedacore/keda/blob/main/pkg/scalers/metrics_api_scaler_test.go. I guess that this feature should be covered by e2e test, but you can base it on the already existing test: https://github.com/kedacore/keda/tree/main/tests/scalers/metrics_api If you have doubts building any component, you can check the build section, there is explained how to build and debug each component |
got it. many thanks. I will work on this issue |
Hey @LuckyDogg this is really good ISSUE, are you working on this? |
I have hacked something quickly in my free time: I did some experiments on kubernetes cluster and it works. |
I think that nobody was working on this 😄 |
Hello @brybacki. Are you planning to turn it into a PR? I am currently experiencing issues related to this, it would be nice to have it solved. |
Hi. Hope you are well. |
Hey! Hope y'all are doing good in this year! I see that we are using gjson as a tool to get value from path. gjson works only for json, which means we would have to get a library for each of the formats we use or create a custom solution. I kinda have a solution (in context of yaml and xml). Also, which formats do we need to support? I presume that clients might have SOAP API's that use xml, but I'm not so sure about yaml. Regardless of the solution, it shall be very well-documented as the usecase is not that simple C: Thanks in advance. |
I've quick reviewed your PR and it looks really nice and I like the approach you've taken tbh. |
Let me get to this in a few days, thanks for the proposal. @wozniakjan FYI |
I'm currently seeking support for the Prometheus format. I noticed that @brybacki has developed something similar in a fork. Is there any possibility of incorporating this into the main branch? I'm considering the creation of a custom scalar due to the urgency of my requirement for Prometheus format. However, before I proceed with the custom scalar, I wanted to explore the option of advancing this feature in the main project. I am willing to take on the responsibility for contributing to this development to ensure its integration |
@smojum can you please give us more detail about the proposal? Prometheus Scaler is not suitable for you? |
The Prometheus Scalar isn't an appropriate solution for us because the Prometheus instance in our cluster operates in agent mode. I believe this mode doesn't support querying. Although it's possible to retrieve metrics from a remote Prometheus server where the data is stored, we want to avoid opening an external connection from our cluster for security reasons. However, we do have metrics available at the service's metrics endpoint. The challenge here is that these metrics are in Prometheus format, as opposed to the JSON format expected by the Metric API scalar. |
Are them aggregated somehow by the prometheus agent? I mean, if you have 5 instances of your API exposing prometheus metrics, despite KEDA can read and understand prometheus format, KEDA won't query and aggregate all the instances, it just query one of them and will scale based on it, which probably isn't what you expect (and we aren't taking into account the option of doing queries, only raw metrics would be available). |
Absolutely valid point. This metrics is something which we are getting from database (and not something which is pod/instance specific). so the value will be consistent irrespective of instance from where we are retrieving the data. |
In general, I am open to exteding the scaler to support additional types. @smojum could you please draft here, what would be the structure and new fields added to the scaler (write an example config). |
triggers:
- type: metrics-api
metadata:
url: http://keda-metric-app-svc.default.svc.cluster.local/prom-metric
targetValue: "30" # Threshold for scaling
format: prometheus # picked this value from the PR (enum)
promMetricLocation: "metric" # name of the metrics e.g. rpc_duration_seconds{quantile="0.99"} including the dimension
promMetricType: "summary" # possible values counter, summary, histogram, gauge. I am thinking this will probably help in parsing the value, may keep as optional
I think we already in the process of adding format. Additional 2 fields are promMetricName and promMetricType. If we need to optimize, we can use existing
triggers:
- type: metrics-api
metadata:
url: http://keda-metric-app-svc.default.svc.cluster.local/prom-metric
targetValue: "30" # Threshold for scaling
format: prometheus # picked this value from the PR (enum)
valueLocation: "rpc_duration_seconds{quantile="0.99"}" # name of the metrics
|
Hi, I prefer Thoughts @kedacore/keda-maintainers @wozniakjan ? // EDIT: corrected preference |
I have a weak preference towards option 2, I feel like additional options dedicated to a specific metric format should be added when there is a direct and known use for them. Also having |
OMG, I agree absolutely with those points, exactly my thoughts. I meant to write that my preference is option 2 but wrote 1 instead, don't know why 🤦♂️ 😄 |
If folks are okay, I can create a PR for Option 2. Please let me know any other thoughts. |
Hello. Hope you all are doing well. I've added some changes to the PR to support Prometheus format. I wonder which formats need to be supported as well. |
Regarding my last comment, I need to add adequate tests for GetValueFromResponse, and if all else is good, then I'll go through checklist, add docs etc. and it's good to be merged afterwards. Please review my PR and if everything looks fine, I'll proceed with it. Thanks in advance! |
any update on this? |
Hello, @abinatarajan |
@zroubalik @wozniakjan |
my bad, I merged the feature without reviewing the docs :( |
Proposal
Extend metrics API scaler to support Prometheus format, or new scaler would be preferable?
I'm thinking something like
or instead of relying on
?format
we can also rely oncontent-type: application/json
will usegjson
andcontent-type: text/plain
will use Prometheus format.unfortunately most of
/metrics
mostly usecontent-type: text/plain
instead of explicitly saying it's PrometheusUse-Case
Currently, metrics API Scaler only support JSON format which is pretty handy if the application exposes metrics using JSON.
but most application currently exposes metrics using Prometheus Metrics format, for example.
Anything else?
I can work on this, in case this feature would be something acceptable
The text was updated successfully, but these errors were encountered: