@@ -54,15 +54,22 @@ func scrape(collector *cwCollector, ch chan<- prometheus.Metric) {
54
54
//This map will hold dimensions name which has been already collected
55
55
valueCollected := map [string ]bool {}
56
56
57
- //Check the special case where the user want all the values. A bit "hacky" but will do the job for now
58
- if (len (metric .ConfMetric .DimensionsSelect )== 0 && len (metric .ConfMetric .DimensionsSelectRegex )== 0 ){
59
- metric .ConfMetric .DimensionsSelectRegex = map [string ]string {}
60
- for _ ,dimension := range metric .ConfMetric .Dimensions {
57
+
58
+ if len (metric .ConfMetric .DimensionsSelectRegex ) == 0 {
59
+ metric .ConfMetric .DimensionsSelectRegex = map [string ]string {}
60
+ }
61
+
62
+ //Check for dimensions who does not have either select or dimensions select_regex and make them select everything using regex
63
+ for _ ,dimension := range metric .ConfMetric .Dimensions {
64
+ _ , found := metric .ConfMetric .DimensionsSelect [dimension ]
65
+ _ , found2 := metric .ConfMetric .DimensionsSelectRegex [dimension ]
66
+ if ! found && ! found2 {
61
67
metric .ConfMetric .DimensionsSelectRegex [dimension ]= ".*"
62
68
}
63
69
}
64
70
65
71
72
+
66
73
for _ , stat := range metric .ConfMetric .Statistics {
67
74
params .Statistics = append (params .Statistics , aws .String (stat ))
68
75
}
@@ -136,6 +143,10 @@ func scrape(collector *cwCollector, ch chan<- prometheus.Metric) {
136
143
//Try to match each dimensions to the regex
137
144
for _ ,dim := range met .Dimensions {
138
145
dimRegex := metric .ConfMetric .DimensionsSelectRegex [* dim .Name ]
146
+ if (dimRegex == "" ){
147
+ dimRegex = "\\ b" + strings .Join (metric .ConfMetric .DimensionsSelect [* dim .Name ],"\\ b|\\ b" )+ "\\ b"
148
+ }
149
+
139
150
match ,_ := regexp .MatchString (dimRegex ,* dim .Value )
140
151
if match {
141
152
dimensions = append (dimensions , & cloudwatch.Dimension {
0 commit comments