Skip to content

Commit

Permalink
Graphite scaler should use latest datapoint, not earliest, returned (k…
Browse files Browse the repository at this point in the history
…edacore#2365)

Signed-off-by: Brandon Pinske <brandon.pinske@crowdstrike.com>
  • Loading branch information
bpinske authored and Brandon Pinske committed Dec 27, 2021
1 parent 8e1abee commit 73cbe54
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

### Improvements

- Graphite Scaler: use the latest datapoint returned, not the earliest (https://github.com/kedacore/keda/pull/2365)

- TODO ([#XXX](https://github.com/kedacore/keda/pull/XXX))

### Breaking Changes
Expand Down
7 changes: 6 additions & 1 deletion pkg/scalers/graphite_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ func (s *graphiteScaler) ExecuteGrapQuery() (float64, error) {
}

// https://graphite-api.readthedocs.io/en/latest/api.html#json
datapoint := result[0].Datapoints[0][0]
if len(result[0].Datapoints) == 0 {
return 0, nil
}

latestDatapoint := len(result[0].Datapoints) - 1
datapoint := result[0].Datapoints[latestDatapoint][0]

return datapoint, nil
}
Expand Down

0 comments on commit 73cbe54

Please sign in to comment.