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

Add Support for Mutli-Queries in Datadog Scaler #3550

Merged
merged 7 commits into from
Sep 12, 2022

Conversation

dgibbard-cisco
Copy link
Contributor

@dgibbard-cisco dgibbard-cisco commented Aug 10, 2022

Signed-off-by: Darren Gibbard dgibbard@cisco.com

Adds support for comma-separated multi-queries in the Datadog Scaler.

Previously, if a query returned more than one element, we would throw an error. With this change, when Datadog returns multiple Series elements, we then apply an average or max operation (set by the queryAggregator parameter) on the latest points from each Series to aggregate the results to a single return value.

This is beneficial to reducing the number of Datadog API Requests being made, which can quickly hit rate limits which impacts scaling.

Checklist

  • Commits are signed with Developer Certificate of Origin (DCO - learn more)
  • Tests have been added
  • A PR is opened to update our Helm chart (repo) (if applicable, ie. when deployment manifests are modified)
  • A PR is opened to update the documentation on (repo) (if applicable)
  • Changelog has been updated and is aligned with our changelog requirements

Fixes #3423

Doc PR Link: kedacore/keda-docs#885

Signed-off-by: Darren Gibbard <dgibbard@cisco.com>
@dgibbard-cisco dgibbard-cisco requested a review from a team as a code owner August 10, 2022 11:21
@dgibbard-cisco dgibbard-cisco changed the title Go fmt Add Support for Mutli-Queries in Datadog Scaler Aug 10, 2022
Signed-off-by: dgibbard-cisco <57677847+dgibbard-cisco@users.noreply.github.com>
@dgibbard-cisco
Copy link
Contributor Author

Would be good to get @arapulido 's eyes on this too if available, as the main code creator :)

Copy link
Contributor

@arapulido arapulido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

I am not super convinced about this, as it starts implementing things like avg or max outside Datadog.

I would accept the change though if we warn the user clearly, and we don't use defaults that can hide what the scaler is doing.

I have added ways of doing that in the inline review. I will review the docs as well.

pkg/scalers/datadog_scaler.go Show resolved Hide resolved
pkg/scalers/datadog_scaler.go Show resolved Hide resolved
pkg/scalers/datadog_scaler.go Show resolved Hide resolved
pkg/scalers/datadog_scaler.go Show resolved Hide resolved
@dgibbard-cisco
Copy link
Contributor Author

I am not super convinced about this, as it starts implementing things like avg or max outside Datadog.

Some context here; Datadog doesn't support running avg/max operations across the results of multiple queries (eg; something like max(query1,query2) is not valid); but they do support returning multiple query result sets, in the form of multiple Series elements.
So we have to do the aggregation ourselves as a result; hence why I got stuck with this :D

Signed-off-by: Darren Gibbard <dgibbard@cisco.com>
@dgibbard-cisco
Copy link
Contributor Author

dgibbard-cisco commented Aug 10, 2022

Pushed some changes so that:

  • Stop non-explicit usage of query aggregation -- if query returns multiple Series and queryAggregator is not set, throw error:

query returned more than 1 series; modify the query to return only 1 series or add a queryAggregator

  • Cleanup logic and remove FindStringInSlice()

@arapulido I think this covers the desire to not have it default, and/or display an error when not explicitly set? As well as the suggested cleanup :)
We still use MaxFloatFromSlice() as the default result return method, just out of convenience of not having to split it if Series is 1 or more.

Signed-off-by: Darren Gibbard <dgibbard@cisco.com>
Copy link
Contributor

@arapulido arapulido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

pkg/scalers/datadog_scaler.go Show resolved Hide resolved
pkg/scalers/datadog_scaler.go Show resolved Hide resolved
pkg/scalers/datadog_scaler.go Show resolved Hide resolved
@zroubalik
Copy link
Member

zroubalik commented Aug 15, 2022

/run-e2e datadog*
Update: You can check the progress here

Signed-off-by: dgibbard-cisco <57677847+dgibbard-cisco@users.noreply.github.com>
@dgibbard-cisco
Copy link
Contributor Author

Resolved conflict with #3617 :)
Might need e2e tests kicked again?

dgibbard-cisco and others added 2 commits September 1, 2022 10:41
Signed-off-by: Darren Gibbard <dgibbard@cisco.com>
Signed-off-by: dgibbard-cisco <57677847+dgibbard-cisco@users.noreply.github.com>
@dgibbard-cisco
Copy link
Contributor Author

@zroubalik - can I trouble you for a re-kick for e2e tests?

@zroubalik
Copy link
Member

zroubalik commented Sep 9, 2022

/run-e2e datadog*
Update: You can check the progress here

Copy link
Member

@JorTurFer JorTurFer left a 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 contribution! ❤️

@JorTurFer JorTurFer merged commit 8cb7a3f into kedacore:main Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Datadog Scaler: Support Multi-Query Results
4 participants