-
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
feat: Add support for formula based evaluation of metrics values #4821
Conversation
Thank you for your contribution! 🙏 We will review your PR as soon as possible.
While you are waiting, make sure to:
Learn more about: |
/assign zroubalik |
will this support boolean operators as well? |
4ef3dc4
to
3686015
Compare
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.
some self-review of what i thought were important points
you can see what you can with the package in here: https://expr.medv.io/docs/Language-Definition |
3686015
to
a7d9f72
Compare
I rechecked everything, hopefully i didnt miss anything. I started a self-review with the structure name. Once this PR is merged I will match the second new feature of the big parent PR of the structure name etc. and open it for a review |
a7d9f72
to
7ec679a
Compare
7ec679a
to
2b69cd8
Compare
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.
First of all, I 💘 this feature! Thanks a ton for implementing it!
I know that it's not something direct, but if we'd have a way to query CPU/Memory metrics to include them in the formula would be nice. I think that using multiple scalers, including the CPU/Memory is a common pattern. Primary scaling based on events, but having CPU/Memory as fallback.
Regarding with the formula calculation, maybe we can move it to it's own file/package to group all the related stuff. Maybe its own package for all the modifiers is worth as there is too much logic only for it this formula calculation and it'll increase in the future
2b69cd8
to
1dddfa6
Compare
Is the doc PR up-to-date with the end-user experience @gauron99? |
its up to date with what i had in mind when i created the PR. Im expecting to change some names of structures etc based on some conversation above if thats what you mean. I have this @tomkerkhove which currently matches the code in this PR |
4fb19ae
to
71b5cf1
Compare
Thanks, added some doc comments: kedacore/keda-docs#1198 (review) |
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.
Great stuff! I think we should mark this feature as an EXPERIMENATAL. This will allow us to change/modify the behavior after the release without the need for backward compatibility.
@zroubalik @JorTurFer @tomkerkhove Currently there are formula help functions in Im thinking of few possibilities:
the question is if its ok for the implementation to be in the |
…dation Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
411e9da
to
35ccadc
Compare
@zroubalik @JorTurFer PTAL 🙏 Ive also created #4992 |
/run-e2e |
LGTM! |
…acore#4821) Signed-off-by: gauron99 <fridrich.david19@gmail.com> Signed-off-by: anton.lysina <alysina@gmail.com>
So I have created (this big PR) but after some comments from others decided to separate it into 2 smaller PRs. So I extracted the functionality of formula and kept it here.
WHATS NEW
This change introduces a new feature I call "formula". The definition lies in SO (see below).
composite-scaler-metric
that is passed on to HPA (hpa.go
). HPA will make a request for thiscomposite-metric
ONLY instead of all external metrics. (resource triggers are untouched). This way all external metrics are collected at the same time and passed on to the formula itself (scale_handler.go
). Formula is a string that specifies some mathematical/conditional statements and returns 1 number which is the final metric. Internally, it uses https://github.com/antonmedv/expr. (see language definition)mapi_trig
andkw_trig
, sums them up and divides by 2 aka creating an average of the 2.Additional info
Formula lies within the
scalingModifiers
struct which is used for additional changes (the second part of the big PR mentioned at the top would go here as well). The struct could also look like this:or it could be separated entirely. The problem is where to put the
target
because it is mandatory for formula and optional for external grpc servers. (if grpc server is given but target not, it will modify each external metric on its own by users definition of Calculate method - more in external metric calculation PR - will open this after struct is decidedChecklist
Fixes #2440
Fixes #4823
Relates to #4583