Skip to content

Commit

Permalink
Don't arbitrarily choose the largest datapoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Pinske committed Sep 8, 2021
1 parent 0321b01 commit 6e9b257
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions pkg/scalers/graphite_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,10 @@ func (s *graphiteScaler) ExecuteGrapQuery() (float64, error) {
return -1, fmt.Errorf("graphite query %s returned multiple series", s.metadata.query)
}

var v float64 = -1
for _, datapoints := range result[0].Datapoints {
if strconv.FormatFloat(datapoints[0], 'f', -1, 64) != "" {
if datapoints[0] > v {
v = datapoints[0]
}
}
}
// https://graphite-api.readthedocs.io/en/latest/api.html#json
datapoint := result[0].Datapoints[0][0]

return v, nil
return datapoint, nil
}

func (s *graphiteScaler) GetMetrics(ctx context.Context, metricName string, metricSelector labels.Selector) ([]external_metrics.ExternalMetricValue, error) {
Expand Down

0 comments on commit 6e9b257

Please sign in to comment.