-
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
Add support for datadog query function wrappers - WIP #2766
Conversation
Signed-off-by: Darren Gibbard <[email protected]>
Signed-off-by: Darren Gibbard <[email protected]>
Signed-off-by: Darren Gibbard <[email protected]>
Signed-off-by: Darren Gibbard <[email protected]>
pkg/scalers/datadog_scaler.go
Outdated
|
||
func init() { | ||
aggregator = regexp.MustCompile(`^(avg|sum|min|max):.*`) | ||
aggregator = regexp.MustCompile(`^([\w]+\()?(avg|sum|min|max):.*`) |
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.
Pardon my ignorance, just looking at all these regexes, isn't there any validator in any Datadog library? That could be used here. What is being used in Datadog to validate this?
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.
An excellent question; will check!
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.
Had a quick look around, plenty for submitting metrics etc, but not a lot in the way of validating if a metrics query is valid.
The Datadog UI posts to https://app.datadoghq.com/api/v2/query/timeseries when changing queries interactively, and returns 400 when it's invalid - but seeing as this requires auth anyway, if going down that route, you may as well skip validation in the Scaler, and just handle errors when they come back from the upstream.
Signed-off-by: Darren Gibbard <[email protected]>
Closing this, as it makes sense to not validate in the code, and instead use the upstream API. |
Allow the Datadog Scaler to parse/validate queries which contain a wrapping function; eg:
Previously, the code would see these as missing an aggregator; and prefix them with
avg:
resulting in an invalid query of:Checklist
Fixes #2761