CloudWatch: Backport aws-sdk-go-v2 update from external plugin (#107136)
* CloudWatch: Backport aws-sdk-go-v2 update from external plugin * Review feedback & cleaning up a couple typos
This commit is contained in:
@@ -8,7 +8,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/service/cloudwatch"
|
||||
"github.com/aws/aws-sdk-go-v2/service/cloudwatch"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/features"
|
||||
@@ -18,7 +19,7 @@ import (
|
||||
// matches a dynamic label
|
||||
var dynamicLabel = regexp.MustCompile(`\$\{.+\}`)
|
||||
|
||||
func (e *cloudWatchExecutor) parseResponse(ctx context.Context, metricDataOutputs []*cloudwatch.GetMetricDataOutput,
|
||||
func (ds *DataSource) parseResponse(ctx context.Context, metricDataOutputs []*cloudwatch.GetMetricDataOutput,
|
||||
queries []*models.CloudWatchQuery) ([]*responseWrapper, error) {
|
||||
aggregatedResponse := aggregateResponse(metricDataOutputs)
|
||||
queriesById := map[string]*models.CloudWatchQuery{}
|
||||
@@ -88,7 +89,7 @@ func aggregateResponse(getMetricDataOutputs []*cloudwatch.GetMetricDataOutput) m
|
||||
}
|
||||
}
|
||||
|
||||
response.AddMetricDataResult(r)
|
||||
response.AddMetricDataResult(&r)
|
||||
responseByID[id] = response
|
||||
}
|
||||
}
|
||||
@@ -228,16 +229,9 @@ func buildDataFrames(ctx context.Context, aggregatedResponse models.QueryRowResp
|
||||
} else {
|
||||
labels = getLabels(label, query, false)
|
||||
}
|
||||
timestamps := []*time.Time{}
|
||||
points := []*float64{}
|
||||
for j, t := range metric.Timestamps {
|
||||
val := metric.Values[j]
|
||||
timestamps = append(timestamps, t)
|
||||
points = append(points, val)
|
||||
}
|
||||
|
||||
timeField := data.NewField(data.TimeSeriesTimeFieldName, nil, timestamps)
|
||||
valueField := data.NewField(data.TimeSeriesValueFieldName, labels, points)
|
||||
timeField := data.NewField(data.TimeSeriesTimeFieldName, nil, metric.Timestamps)
|
||||
valueField := data.NewField(data.TimeSeriesValueFieldName, labels, metric.Values)
|
||||
|
||||
// CloudWatch appends the dimensions to the returned label if the query label is not dynamic, so static labels need to be set
|
||||
if hasStaticLabel {
|
||||
|
||||
Reference in New Issue
Block a user