Skip to content

Commit

Permalink
fix flow error (#4964)
Browse files Browse the repository at this point in the history
  • Loading branch information
nowinkeyy authored Aug 14, 2024
1 parent e2f66e5 commit 331229e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions controllers/pkg/objectstorage/objectstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,24 @@ func QueryPrometheus(host, bucketName, instance string, startTime, endTime time.
return 0, fmt.Errorf("failed to query Prometheus: %w", err)
}

if rcvdValues[0] <= 0 || rcvdValues[1] <= 0 {
fmt.Println("[Warning] The metrics retrieved by vector-metrics are less than or equal to 0.", "bucket:", bucketName)
fmt.Printf("received bytes: {startTime: {time: %v, value: %v}, endTime: {time: %v, value: %v}}\n", startTime.Format(timeFormat), rcvdValues[0], endTime.Format(timeFormat), rcvdValues[1])
return 0, nil
}

sentQuery := fmt.Sprintf("sum(minio_bucket_traffic_sent_bytes{bucket=\"%s\", instance=\"%s\"})", bucketName, instance)
sentValues, err := queryPrometheus(ctx, v1api, sentQuery, startTime, endTime)
if err != nil {
return 0, fmt.Errorf("failed to query Prometheus: %w", err)
}

if sentValues[0] <= 0 || sentValues[1] <= 0 {
fmt.Println("[Warning] The metrics retrieved by vector-metrics are less than or equal to 0.", "bucket:", bucketName)
fmt.Printf("sent bytes: {startTime: {time: %v, value: %v}, endTime: {time: %v, value: %v}}\n", startTime.Format(timeFormat), sentValues[0], endTime.Format(timeFormat), sentValues[1])
return 0, nil
}

receivedDiff := rcvdValues[1] - rcvdValues[0]
sentDiff := sentValues[1] - sentValues[0]

Expand Down

0 comments on commit 331229e

Please sign in to comment.