CloudWatch: Add support for AWS Metric Insights (#42487) (#42506)

* add support for code editor and builder

* refactor cloudwatch migration

* Add tooltip to editor field (#56)

* add tooltip

* add old tooltips

* Bug bash feedback fixes (#58)

* make ASC the default option

* update sql preview whenever sql changes

* don't allow queries without aggregation

* set default value for aggregation

* use new input field

* cleanup

* pr feedback

* prevent unnecessary rerenders

* use frame error instead of main error

* remove not used snapshot

* Use dimension filter in schema picker  (#63)

* use dimension key filter in group by and schema labels

* add dimension filter also to code editor

* add tests

* fix build error

* fix strict error

* remove debug code

* fix annotation editor (#64)

* fix annotation editor

* fix broken test

* revert annotation backend change

* PR feedback (#67)

* pr feedback

* removed dimension filter from group by

* add spacing between common fields and rest

* do not generate deep link for metric queries (#70)

* update docs (#69)

Co-authored-by: Erik Sundell <erik.sundell87@gmail.com>

* fix lint problem caused by merge conflict

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
(cherry picked from commit bab78a9e64)

Co-authored-by: Erik Sundell <erik.sundell@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2021-11-30 11:10:15 +01:00
committed by GitHub
co-authored by Erik Sundell
parent 7f64f3b773
commit 0f53eab992
86 changed files with 6487 additions and 1010 deletions
+25 -7
View File
@@ -2,11 +2,36 @@ package cloudwatch
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCloudWatchQuery(t *testing.T) {
t.Run("Deeplink is not generated for MetricQueryTypeQuery", func(t *testing.T) {
startTime := time.Now()
endTime := startTime.Add(2 * time.Hour)
query := &cloudWatchQuery{
RefId: "A",
Region: "us-east-1",
Expression: "",
Statistic: "Average",
Period: 300,
Id: "id1",
MatchExact: true,
Dimensions: map[string][]string{
"InstanceId": {"i-12345678"},
},
MetricQueryType: MetricQueryTypeQuery,
MetricEditorMode: MetricEditorModeBuilder,
}
deepLink, err := query.buildDeepLink(startTime, endTime)
require.NoError(t, err)
assert.Empty(t, deepLink)
})
t.Run("SEARCH(someexpression) was specified in the query editor", func(t *testing.T) {
query := &cloudWatchQuery{
RefId: "A",
@@ -107,14 +132,12 @@ func TestCloudWatchQuery(t *testing.T) {
query.MatchExact = false
assert.True(t, query.isSearchExpression(), "Expected a search expression")
assert.False(t, query.isMathExpression(), "Expected not math expression")
assert.False(t, query.isMetricStat(), "Expected not metric stat")
})
t.Run("Match exact is true", func(t *testing.T) {
query.MatchExact = true
assert.False(t, query.isSearchExpression(), "Exxpected not search expression")
assert.False(t, query.isMathExpression(), "Expected not math expression")
assert.True(t, query.isMetricStat(), "Expected a metric stat")
})
})
@@ -134,10 +157,5 @@ func TestCloudWatchQuery(t *testing.T) {
assert.True(t, query.isSearchExpression(), "Expected search expression")
assert.False(t, query.isMathExpression(), "Expected not math expression")
assert.False(t, query.isMetricStat(), "Expected not metric stat")
})
}
func (q *cloudWatchQuery) isMetricStat() bool {
return !q.isSearchExpression() && !q.isMathExpression()
}