@@ -2,6 +2,7 @@ package metrics
22
33import (
44 "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights"
5+ "github.com/Azure/go-autorest/autorest/to"
56 "github.com/prometheus/client_golang/prometheus"
67 "regexp"
78 "strings"
@@ -121,15 +122,20 @@ func (r *AzureInsightMetricsResult) SendMetricToChannel(channel chan<- Prometheu
121122 }
122123 }
123124
125+ resourceId := to .String (r .ResourceID )
126+ if r .settings .LowercaseResourceId {
127+ resourceId = strings .ToLower (resourceId )
128+ }
129+
124130 if timeseriesData .Total != nil {
125131 channel <- r .buildMetric (
126132 prometheus.Labels {
127- "resourceID" : * r . ResourceID ,
128- "metric" : stringPtrToString (metric .Name .Value ),
133+ "resourceID" : resourceId ,
134+ "metric" : to . String (metric .Name .Value ),
129135 "dimension" : dimensionName ,
130136 "unit" : string (metric .Unit ),
131137 "aggregation" : "total" ,
132- "interval" : stringPtrToString (r .settings .Interval ),
138+ "interval" : to . String (r .settings .Interval ),
133139 "timespan" : r .settings .Timespan ,
134140 },
135141 * timeseriesData .Total ,
@@ -139,12 +145,12 @@ func (r *AzureInsightMetricsResult) SendMetricToChannel(channel chan<- Prometheu
139145 if timeseriesData .Minimum != nil {
140146 channel <- r .buildMetric (
141147 prometheus.Labels {
142- "resourceID" : * r . ResourceID ,
143- "metric" : stringPtrToString (metric .Name .Value ),
148+ "resourceID" : resourceId ,
149+ "metric" : to . String (metric .Name .Value ),
144150 "dimension" : dimensionName ,
145151 "unit" : string (metric .Unit ),
146152 "aggregation" : "minimum" ,
147- "interval" : stringPtrToString (r .settings .Interval ),
153+ "interval" : to . String (r .settings .Interval ),
148154 "timespan" : r .settings .Timespan ,
149155 },
150156 * timeseriesData .Minimum ,
@@ -154,12 +160,12 @@ func (r *AzureInsightMetricsResult) SendMetricToChannel(channel chan<- Prometheu
154160 if timeseriesData .Maximum != nil {
155161 channel <- r .buildMetric (
156162 prometheus.Labels {
157- "resourceID" : * r . ResourceID ,
158- "metric" : stringPtrToString (metric .Name .Value ),
163+ "resourceID" : resourceId ,
164+ "metric" : to . String (metric .Name .Value ),
159165 "dimension" : dimensionName ,
160166 "unit" : string (metric .Unit ),
161167 "aggregation" : "maximum" ,
162- "interval" : stringPtrToString (r .settings .Interval ),
168+ "interval" : to . String (r .settings .Interval ),
163169 "timespan" : r .settings .Timespan ,
164170 },
165171 * timeseriesData .Maximum ,
@@ -169,12 +175,12 @@ func (r *AzureInsightMetricsResult) SendMetricToChannel(channel chan<- Prometheu
169175 if timeseriesData .Average != nil {
170176 channel <- r .buildMetric (
171177 prometheus.Labels {
172- "resourceID" : * r . ResourceID ,
173- "metric" : stringPtrToString (metric .Name .Value ),
178+ "resourceID" : resourceId ,
179+ "metric" : to . String (metric .Name .Value ),
174180 "dimension" : dimensionName ,
175181 "unit" : string (metric .Unit ),
176182 "aggregation" : "average" ,
177- "interval" : stringPtrToString (r .settings .Interval ),
183+ "interval" : to . String (r .settings .Interval ),
178184 "timespan" : r .settings .Timespan ,
179185 },
180186 * timeseriesData .Average ,
@@ -184,12 +190,12 @@ func (r *AzureInsightMetricsResult) SendMetricToChannel(channel chan<- Prometheu
184190 if timeseriesData .Count != nil {
185191 channel <- r .buildMetric (
186192 prometheus.Labels {
187- "resourceID" : * r . ResourceID ,
188- "metric" : stringPtrToString (metric .Name .Value ),
193+ "resourceID" : resourceId ,
194+ "metric" : to . String (metric .Name .Value ),
189195 "dimension" : dimensionName ,
190196 "unit" : string (metric .Unit ),
191197 "aggregation" : "count" ,
192- "interval" : stringPtrToString (r .settings .Interval ),
198+ "interval" : to . String (r .settings .Interval ),
193199 "timespan" : r .settings .Timespan ,
194200 },
195201 * timeseriesData .Count ,
0 commit comments