Skip to content

Commit a0c5d4b

Browse files
committed
fix(collector): get the last value in run-ai returned metrics
1 parent 42ed986 commit a0c5d4b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

collector/benthos/input/runai/metrics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (s *Service) GetWorkloadMetrics(ctx context.Context, workloadID string, par
103103

104104
for _, measurement := range result.Measurements {
105105
if len(measurement.Values) > 0 {
106-
v, err := strconv.ParseFloat(measurement.Values[0].Value, 64)
106+
v, err := strconv.ParseFloat(measurement.Values[len(measurement.Values)-1].Value, 64)
107107
if err != nil {
108108
return m, fmt.Errorf("failed to parse metric value: %w", err)
109109
}
@@ -240,7 +240,7 @@ func (s *Service) GetPodMetrics(ctx context.Context, workloadID string, podID st
240240

241241
for _, measurement := range result.Measurements {
242242
if len(measurement.Values) > 0 {
243-
v, err := strconv.ParseFloat(measurement.Values[0].Value, 64)
243+
v, err := strconv.ParseFloat(measurement.Values[len(measurement.Values)-1].Value, 64)
244244
if err != nil {
245245
return m, fmt.Errorf("failed to parse metric value: %w", err)
246246
}

0 commit comments

Comments
 (0)