mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
b5f26560c2
* Cloudwatch: use logging from plugin-sdk-go instead of infra/log * Add a link to the TODO issue for moving `instrumentContext`
38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package cloudwatch
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/aws/aws-sdk-go/aws"
|
|
"github.com/aws/aws-sdk-go/service/cloudwatch"
|
|
|
|
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models"
|
|
)
|
|
|
|
func (e *cloudWatchExecutor) buildMetricDataInput(startTime time.Time, endTime time.Time,
|
|
queries []*models.CloudWatchQuery) (*cloudwatch.GetMetricDataInput, error) {
|
|
metricDataInput := &cloudwatch.GetMetricDataInput{
|
|
StartTime: aws.Time(startTime),
|
|
EndTime: aws.Time(endTime),
|
|
ScanBy: aws.String("TimestampAscending"),
|
|
}
|
|
|
|
shouldSetLabelOptions := len(queries) > 0 && len(queries[0].TimezoneUTCOffset) > 0
|
|
|
|
if shouldSetLabelOptions {
|
|
metricDataInput.LabelOptions = &cloudwatch.LabelOptions{
|
|
Timezone: aws.String(queries[0].TimezoneUTCOffset),
|
|
}
|
|
}
|
|
|
|
for _, query := range queries {
|
|
metricDataQuery, err := e.buildMetricDataQuery(query)
|
|
if err != nil {
|
|
return nil, &models.QueryError{Err: err, RefID: query.RefId}
|
|
}
|
|
metricDataInput.MetricDataQueries = append(metricDataInput.MetricDataQueries, metricDataQuery)
|
|
}
|
|
|
|
return metricDataInput, nil
|
|
}
|