grafana/pkg/tsdb/cloudwatch/metric_data_input_builder.go
Arve Knudsen c863fd3da9
CloudWatch: Clean up code (#26259)
* CloudWatch: Clean up code
2020-07-14 08:23:23 +02:00

27 lines
748 B
Go

package cloudwatch
import (
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudwatch"
)
func (e *cloudWatchExecutor) buildMetricDataInput(startTime time.Time, endTime time.Time,
queries map[string]*cloudWatchQuery) (*cloudwatch.GetMetricDataInput, error) {
metricDataInput := &cloudwatch.GetMetricDataInput{
StartTime: aws.Time(startTime),
EndTime: aws.Time(endTime),
ScanBy: aws.String("TimestampAscending"),
}
for _, query := range queries {
metricDataQuery, err := e.buildMetricDataQuery(query)
if err != nil {
return nil, &queryError{err, query.RefId}
}
metricDataInput.MetricDataQueries = append(metricDataInput.MetricDataQueries, metricDataQuery)
}
return metricDataInput, nil
}