mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CloudWatch: Expand dimension value in alias correctly (#21626)
* Make sure dimension value is being returned, and not just label * Fix typo
This commit is contained in:
parent
5f332682ec
commit
a1733bb412
@ -100,7 +100,7 @@ func (e *CloudWatchExecutor) transformQueryResponseToQueryResult(cloudwatchRespo
|
||||
}
|
||||
|
||||
if partialData {
|
||||
queryResult.ErrorString = "Cloudwatch GetMetricData error: Too many datapoints requested - your search have been limited. Please try to reduce the time range"
|
||||
queryResult.ErrorString = "Cloudwatch GetMetricData error: Too many datapoints requested - your search has been limited. Please try to reduce the time range"
|
||||
}
|
||||
|
||||
queryResult.Series = append(queryResult.Series, timeSeries...)
|
||||
|
@ -100,8 +100,10 @@ func parseGetMetricDataTimeSeries(metricDataResults map[string]*cloudwatch.Metri
|
||||
series.Tags[key] = values[0]
|
||||
} else {
|
||||
for _, value := range values {
|
||||
if value == label || value == "*" || strings.Contains(label, value) {
|
||||
if value == label || value == "*" {
|
||||
series.Tags[key] = label
|
||||
} else if strings.Contains(label, value) {
|
||||
series.Tags[key] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ func TestCloudWatchResponseParser(t *testing.T) {
|
||||
Namespace: "AWS/ApplicationELB",
|
||||
MetricName: "TargetResponseTime",
|
||||
Dimensions: map[string][]string{
|
||||
"LoadBalancer": {"lb2"},
|
||||
"LoadBalancer": {"lb1", "lb2"},
|
||||
"TargetGroup": {"tg"},
|
||||
},
|
||||
Stats: "Average",
|
||||
@ -65,8 +65,12 @@ func TestCloudWatchResponseParser(t *testing.T) {
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
So(partialData, ShouldBeFalse)
|
||||
So(timeSeries.Name, ShouldEqual, "lb2 Expanded")
|
||||
So(timeSeries.Tags["LoadBalancer"], ShouldEqual, "lb2")
|
||||
So(timeSeries.Name, ShouldEqual, "lb1 Expanded")
|
||||
So(timeSeries.Tags["LoadBalancer"], ShouldEqual, "lb1")
|
||||
|
||||
timeSeries2 := (*series)[1]
|
||||
So(timeSeries2.Name, ShouldEqual, "lb2 Expanded")
|
||||
So(timeSeries2.Tags["LoadBalancer"], ShouldEqual, "lb2")
|
||||
})
|
||||
|
||||
Convey("can expand dimension value using substring", func() {
|
||||
@ -110,7 +114,7 @@ func TestCloudWatchResponseParser(t *testing.T) {
|
||||
Namespace: "AWS/ApplicationELB",
|
||||
MetricName: "TargetResponseTime",
|
||||
Dimensions: map[string][]string{
|
||||
"LoadBalancer": {"lb1"},
|
||||
"LoadBalancer": {"lb1", "lb2"},
|
||||
"TargetGroup": {"tg"},
|
||||
},
|
||||
Stats: "Average",
|
||||
@ -119,11 +123,14 @@ func TestCloudWatchResponseParser(t *testing.T) {
|
||||
}
|
||||
series, partialData, err := parseGetMetricDataTimeSeries(resp, query)
|
||||
timeSeries := (*series)[0]
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
So(partialData, ShouldBeFalse)
|
||||
So(timeSeries.Name, ShouldEqual, "lb1 Expanded")
|
||||
So(timeSeries.Tags["LoadBalancer"], ShouldEqual, "lb1")
|
||||
|
||||
timeSeries2 := (*series)[1]
|
||||
So(timeSeries2.Name, ShouldEqual, "lb2 Expanded")
|
||||
So(timeSeries2.Tags["LoadBalancer"], ShouldEqual, "lb2")
|
||||
})
|
||||
|
||||
Convey("can expand dimension value using wildcard", func() {
|
||||
|
Loading…
Reference in New Issue
Block a user