Browse Source

stackdriver: always use regex full match for =~ and !=~operator

Erik Sundell 7 years ago
parent
commit
8d53799bcd
1 changed files with 5 additions and 1 deletions
  1. 5 1
      pkg/tsdb/stackdriver/stackdriver.go

+ 5 - 1
pkg/tsdb/stackdriver/stackdriver.go

@@ -199,7 +199,11 @@ func buildFilterString(metricType string, filterParts []interface{}) string {
 		if part == "AND" {
 			filterString += " "
 		} else if mod == 2 {
-			if strings.Contains(part.(string), "*") {
+			operator := filterParts[i-1]
+			if operator == "=~" || operator == "!=~" {
+				filterString = reverse(strings.Replace(reverse(filterString), "~", "", 1))
+				filterString += fmt.Sprintf(`monitoring.regex.full_match("%s")`, part)
+			} else if strings.Contains(part.(string), "*") {
 				filterString += interpolateFilterWildcards(part.(string))
 			} else {
 				filterString += fmt.Sprintf(`"%s"`, part)