Cloudwatch: Round up endTime in GetMetricData to next minute (#89341)
* Add cloudWatchRoundUpEndTime feature toggle
This commit is contained in:
@@ -2,10 +2,12 @@ package cloudwatch
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/cloudwatch"
|
||||
"github.com/aws/aws-sdk-go/service/cloudwatch/cloudwatchiface"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/features"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
)
|
||||
|
||||
@@ -18,6 +20,11 @@ func (e *cloudWatchExecutor) executeRequest(ctx context.Context, client cloudwat
|
||||
if nextToken != "" {
|
||||
metricDataInput.NextToken = aws.String(nextToken)
|
||||
}
|
||||
// GetMetricData EndTime is exclusive, so we round up to the next minute to get the last data point
|
||||
if features.IsEnabled(ctx, features.FlagCloudWatchRoundUpEndTime) {
|
||||
*metricDataInput.EndTime = metricDataInput.EndTime.Truncate(time.Minute).Add(time.Minute)
|
||||
}
|
||||
|
||||
resp, err := client.GetMetricDataWithContext(ctx, metricDataInput)
|
||||
if err != nil {
|
||||
return mdo, err
|
||||
|
||||
Reference in New Issue
Block a user