-
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
Support custom formula for multiple metrics #2440
Comments
Having had a dig through the code, the I would be tempted by implementing this using a Go template. In scaledObject.spec:
...
derivedMetric: # better name?
formula: "ceil(mulf(subf(1 .cpu_util) .q_length))"
targetMetricValue: "5"
minMetricValue: "0"
triggers:
- type: aws-cloudwatch
name: q_length
metadata:
namespace: AWS/SQS
... # SQS length
- type: aws-cloudwatch
name: cpu_util
metadata:
namespace: AWS/Neptune
... # neptune writer CPU The implementation would be rendering that template and converting the resulting string representation into a number to send to the HPA. |
Prior discussion: #373 (comment) |
2 use case ideas: It's my understanding that currently if you have multiple triggers they OR and take the largest desired count of the multiple triggers, some people mentioned it'd be useful to have AND logic. This formula might be a good opportunity to implement AND logic to cover those scenarios as well. |
Proposal
I think that a "Composed Scaler" that allows to put in a simple formula that references multiple other metrics - can be super useful.
This would make Keda a powerful tool not only for collecting external metrics but also for making smart decisions based on multiple conditions.
(discussed original here)
Use-Case
Here's a real-world problem: I have a backend process that consumes "write" tasks from a queue and persists them to DB. My DB has a single writer node that is CPU-bound. A task may implicit varying load on the CPU (depending on the content of the write).
I have 2 relevant metrics to determine the replica count:
Composed metric formula:
ceil((1-cpu) * q)
can promise that replicas would grow if the queue is high but avoid growing if CPU is loaded. Right now the only option for me to do it is to create my own service that exposes that metric.Anything else?
In the original discussion, we started talking about how the ScaledObject spec would look like in the custom logic case.
First I suggested this:
then @zroubalik suggested this (better IMO):
Finally, it's valuable to read @tomkerkhove 's comment about it.
The text was updated successfully, but these errors were encountered: