-
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
gcp_pubsub: Support distribution-valued metrics and metrics from topics #5246
gcp_pubsub: Support distribution-valued metrics and metrics from topics #5246
Conversation
…rics Signed-off-by: Kevin Mingtarja <kevin.mingtarja@gmail.com>
Thank you for your contribution! 🙏 We will review your PR as soon as possible. While you are waiting, make sure to:
Learn more about: |
Signed-off-by: Kevin Mingtarja <kevin.mingtarja@gmail.com>
Signed-off-by: Kevin Mingtarja <kevin.mingtarja@gmail.com>
Signed-off-by: Kevin Mingtarja <kevin.mingtarja@gmail.com>
61ddd4e
to
4e4cded
Compare
For reference, this is what it's going to look like to scale based on the rate of messages being published to a topic:
This calculates a count of messages being sent to a topic by applying a count aggregator to the topic/message_sizes metric (which is a distribution-valued metric). Internally, this is the MQL query that is generated from the above and fired to GCP's API.
|
One of the CI seems to be failing on |
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.
Thanks a lot for the contribution, could you please also add e2e test for this scenario?
Existing GCP tests: https://github.com/kedacore/keda/tree/main/tests/scalers/gcp
Test infra, if anything is needed to be modified on the GCP setup: https://github.com/kedacore/testing-infrastructure/tree/main/terraform/modules/gcp
Signed-off-by: Kevin Mingtarja <kevin.mingtarja@gmail.com>
…keda into gcp_pubsub_topic_monitor
Signed-off-by: Kevin Mingtarja <kevin.mingtarja@gmail.com>
Hi @zroubalik, I've added an e2e test for this scenario. I copied the test from I think no change is needed on the test infra side, since the existing GCP service account should have enough permissions, as i didnt change the setup step as well from |
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.
@kevinmingtarja thanks a lot!
I wonder whether we shouldn't include your test into the existing gcp_pubsub test, just add another test case that will test different ScaledObject. Because majority of the testcode is same. @JorTurFer WDYT?
yeah, if almost all the code is the same, I'd extend current test, but I don't have any strong opinion being honest. With rabbit we use multiple test cases too |
Signed-off-by: Kevin Mingtarja <kevin.mingtarja@gmail.com>
Just a heads up, I fixed the merge conflicts due to PR #5258, refactored it a bit and wrote a test, and at the same time included the changes from there in the new Also, it seems like CI is failing again on an unrelated test ( |
/run-e2e gcp |
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.
LGTM, thanks for the great contribution! Awesome feature.
Thanks @zroubalik for the review! |
…cs (kedacore#5246) Signed-off-by: Kevin Mingtarja <kevin.mingtarja@gmail.com> Signed-off-by: anton.lysina <alysina@gmail.com>
This PR does two main things:
Support distribution-valued metrics for pubsub by exposing a new
aggregation
field:Previously, only single-valued metrics are supported, because we didn't do any aggregations in our query to GCP and without aggregations, distribution-valued metrics are not meaningful. With this change, it opens up a wide range of possibilities of trigger events, for example, scaling based on median or p99 of subscription/ack_latencies, etc.
Support metrics from topics by exposing a new
topicName
field:Previously, only metrics from subscriptions are available to use. With this change, it unlocks more use cases, but the main one is that it enables users to scale based on the rate of incoming messages from the publisher, for example by using topic/send_request_count, or a count/sum of topic/message_sizes.
This is the main request from issue Add support for scaling by Google Pub/Sub subscription publish rate #5070.
I designed it such that there are no breaking API changes to the
gcp_pubsub
scaler, only addition of two new fields,topicName
andaggregation
.Internal API changes:
QueryMetrics()
method inStackDriverClient
, which under the hood calls GCP'sQueryTimeSeries()
. This is done because (1) I couldn't figure out how to properly do the aggregation with theGetMetrics()
method. And (2) it provides a more expressive way of querying as well, as it uses the newer and better Monitoring Query Language (MQL) from GCP, as compared to the old stackdriver (old name for GCP's monitoring suite) filters we're currently using inGetMetrics()
. This allows us to expose a simpler API as well to users.Checklist
Fixes #5070
Relates to kedacore/keda-docs#1271