@@ -192,44 +192,53 @@ func (p *MetricProber) collectMetricsFromSubscriptions() {
192192 return
193193 }
194194
195- resultType := armmonitor .MetricResultTypeData
196- opts := armmonitor.MetricsClientListAtSubscriptionScopeOptions {
197- Interval : p .settings .Interval ,
198- Timespan : to .StringPtr (p .settings .Timespan ),
199- Metricnames : to .StringPtr (strings .Join (p .settings .Metrics , "," )),
200- Metricnamespace : to .StringPtr (p .settings .ResourceType ),
201- Top : p .settings .MetricTop ,
202- AutoAdjustTimegrain : to .BoolPtr (true ),
203- ResultType : & resultType ,
204- Filter : to .StringPtr (`Microsoft.ResourceId eq '*'` ),
205- }
195+ // request metrics in 20 metrics chunks (azure metric api limitation)
196+ for i := 0 ; i < len (p .settings .Metrics ); i += AzureMetricApiMaxMetricNumber {
197+ end := i + AzureMetricApiMaxMetricNumber
198+ if end > len (p .settings .Metrics ) {
199+ end = len (p .settings .Metrics )
200+ }
201+ metricList := p .settings .Metrics [i :end ]
202+
203+ resultType := armmonitor .MetricResultTypeData
204+ opts := armmonitor.MetricsClientListAtSubscriptionScopeOptions {
205+ Interval : p .settings .Interval ,
206+ Timespan : to .StringPtr (p .settings .Timespan ),
207+ Metricnames : to .StringPtr (strings .Join (metricList , "," )),
208+ Metricnamespace : to .StringPtr (p .settings .ResourceType ),
209+ Top : p .settings .MetricTop ,
210+ AutoAdjustTimegrain : to .BoolPtr (true ),
211+ ResultType : & resultType ,
212+ Filter : to .StringPtr (`Microsoft.ResourceId eq '*'` ),
213+ }
206214
207- if len (p .settings .Aggregations ) >= 1 {
208- opts .Aggregation = to .StringPtr (strings .Join (p .settings .Aggregations , "," ))
209- }
215+ if len (p .settings .Aggregations ) >= 1 {
216+ opts .Aggregation = to .StringPtr (strings .Join (p .settings .Aggregations , "," ))
217+ }
210218
211- if len (p .settings .MetricFilter ) >= 1 {
212- opts .Filter = to .StringPtr (* opts .Filter + " and " + p .settings .MetricFilter )
213- }
219+ if len (p .settings .MetricFilter ) >= 1 {
220+ opts .Filter = to .StringPtr (* opts .Filter + " and " + p .settings .MetricFilter )
221+ }
214222
215- if len (p .settings .MetricOrderBy ) >= 1 {
216- opts .Orderby = to .StringPtr (p .settings .MetricOrderBy )
217- }
223+ if len (p .settings .MetricOrderBy ) >= 1 {
224+ opts .Orderby = to .StringPtr (p .settings .MetricOrderBy )
225+ }
218226
219- response , err := client .ListAtSubscriptionScope (p .ctx , region , & opts )
220- if err != nil {
221- // FIXME: find a better way to report errors
222- p .logger .Error (err )
223- return
224- }
227+ response , err := client .ListAtSubscriptionScope (p .ctx , region , & opts )
228+ if err != nil {
229+ // FIXME: find a better way to report errors
230+ p .logger .Error (err )
231+ return
232+ }
225233
226- result := AzureInsightSubscriptionMetricsResult {
227- AzureInsightBaseMetricsResult : AzureInsightBaseMetricsResult {
228- prober : p ,
229- },
230- subscriptionID : subscriptionId ,
231- Result : & response }
232- result .SendMetricToChannel (metricsChannel )
234+ result := AzureInsightSubscriptionMetricsResult {
235+ AzureInsightBaseMetricsResult : AzureInsightBaseMetricsResult {
236+ prober : p ,
237+ },
238+ subscriptionID : subscriptionId ,
239+ Result : & response }
240+ result .SendMetricToChannel (metricsChannel )
241+ }
233242
234243 if p .callbackSubscriptionFishish != nil {
235244 p .callbackSubscriptionFishish (subscriptionId )
0 commit comments