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

fix/datadog-scaler-null-last-point #3954

Merged
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
- **New Relic Scaler** Store forgotten logger ([#3945](https://github.com/kedacore/keda/issues/3945))
- **Prometheus Scaler:** Treat Inf the same as Null result ([#3644](https://github.com/kedacore/keda/issues/3644))
- **NATS Jetstream:** Correctly count messages that should be redelivered (waiting for ack) towards keda value ([#3787](https://github.com/kedacore/keda/issues/3787))
- **Datadog Scaler** The last data point of some specific query is always null ([#3906](https://github.com/kedacore/keda/issues/3906))
dogzzdogzz marked this conversation as resolved.
Show resolved Hide resolved

### Deprecations

Expand Down
7 changes: 7 additions & 0 deletions pkg/scalers/datadog_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,13 @@ func (s *datadogScaler) getQueryResult(ctx context.Context) (float64, error) {
for i := 0; i < len(series); i++ {
points := series[i].GetPointlist()
index := len(points) - 1
// Find out the last point != nil
for i := len(points) - 1; i >= 0; i-- {
if len(points[index]) >= 2 && points[i][1] != nil {
index = i
break
}
}
zroubalik marked this conversation as resolved.
Show resolved Hide resolved
if len(points) == 0 || len(points[index]) < 2 || points[index][1] == nil {
if !s.metadata.useFiller {
return 0, fmt.Errorf("no Datadog metrics returned for the given time window")
Expand Down