-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CloudWatch: Datasource improvements (#20268)
* CloudWatch: Datasource improvements * Add statistic as template variale * Add wildcard to list of values * Template variable intercept dimension key * Return row specific errors when transformation error occured * Add meta feedback * Make it possible to retrieve values without known metrics * Add curated dashboard for EC2 * Fix broken tests * Use correct dashboard name * Display alert in case multi template var is being used for some certain props in the cloudwatch query * Minor fixes after feedback * Update dashboard json * Update snapshot test * Make sure region default is intercepted in cloudwatch link * Update dashboards * Include ec2 dashboard in ds * Do not include ec2 dashboard in beta1 * Display actual region
- Loading branch information
Showing
62 changed files
with
7,527 additions
and
1,512 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package cloudwatch | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
type cloudWatchQuery struct { | ||
RefId string | ||
Region string | ||
Id string | ||
Namespace string | ||
MetricName string | ||
Stats string | ||
Expression string | ||
ReturnData bool | ||
Dimensions map[string][]string | ||
Period int | ||
Alias string | ||
Identifier string | ||
HighResolution bool | ||
MatchExact bool | ||
UsedExpression string | ||
RequestExceededMaxLimit bool | ||
} | ||
|
||
func (q *cloudWatchQuery) isMathExpression() bool { | ||
return q.Expression != "" && !q.isUserDefinedSearchExpression() | ||
} | ||
|
||
func (q *cloudWatchQuery) isSearchExpression() bool { | ||
return q.isUserDefinedSearchExpression() || q.isInferredSearchExpression() | ||
} | ||
|
||
func (q *cloudWatchQuery) isUserDefinedSearchExpression() bool { | ||
return strings.Contains(q.Expression, "SEARCH(") | ||
} | ||
|
||
func (q *cloudWatchQuery) isInferredSearchExpression() bool { | ||
if len(q.Dimensions) == 0 { | ||
return !q.MatchExact | ||
} | ||
|
||
if !q.MatchExact { | ||
return true | ||
} | ||
|
||
for _, values := range q.Dimensions { | ||
if len(values) > 1 { | ||
return true | ||
} | ||
for _, v := range values { | ||
if v == "*" { | ||
return true | ||
} | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func (q *cloudWatchQuery) isMetricStat() bool { | ||
return !q.isSearchExpression() && !q.isMathExpression() | ||
} |
Oops, something went wrong.