diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index d4ea1ebaf406..60053a5c393a 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -130,6 +130,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Resolve statsd module's prematurely halting of metrics parsing upon encountering an invalid packet. {pull}35075[35075] - Fix the gap in fetching forecast API metrics at the end of each month for Azure billing module {pull}36142[36142] - Add option in SQL module to execute queries for all dbs. {pull}35688[35688] +- Fix Azure Monitor empty metricnamespace. {pull}36295[36295] - Fix GCP compute metadata. {pull}36338[36338] - Add support for api_key authentication in elasticsearch module {pull}36274[36274] - Add remaining dimensions for azure storage account to make them available for tsdb enablement. {pull}36331[36331] diff --git a/x-pack/metricbeat/module/azure/monitor_service.go b/x-pack/metricbeat/module/azure/monitor_service.go index 9196a386c667..823a9cdf22a0 100644 --- a/x-pack/metricbeat/module/azure/monitor_service.go +++ b/x-pack/metricbeat/module/azure/monitor_service.go @@ -197,9 +197,13 @@ func (service *MonitorService) GetMetricNamespaces(resourceId string) (armmonito // GetMetricDefinitions will return all supported metrics based on the resource id and namespace func (service *MonitorService) GetMetricDefinitions(resourceId string, namespace string) (armmonitor.MetricDefinitionCollection, error) { - pager := service.metricDefinitionClient.NewListPager(resourceId, &armmonitor.MetricDefinitionsClientListOptions{ - Metricnamespace: &namespace, - }) + opts := &armmonitor.MetricDefinitionsClientListOptions{} + + if namespace != "" { + opts.Metricnamespace = &namespace + } + + pager := service.metricDefinitionClient.NewListPager(resourceId, opts) metricDefinitionCollection := armmonitor.MetricDefinitionCollection{} @@ -246,17 +250,22 @@ func (service *MonitorService) GetMetricValues(resourceId string, namespace stri metricNames := strings.Join(metricNames[i:end], ",") - resp, err := service.metricsClient.List(service.context, resourceId, &armmonitor.MetricsClientListOptions{ - Aggregation: &aggregations, - Filter: metricsFilter, - Interval: tg, - Metricnames: &metricNames, - Metricnamespace: &namespace, - Timespan: ×pan, - Top: nil, + opts := &armmonitor.MetricsClientListOptions{ + Aggregation: &aggregations, + Filter: metricsFilter, + Interval: tg, + Metricnames: &metricNames, + Timespan: ×pan, + Top: nil, // Orderby: &orderBy, ResultType: &resultTypeData, - }) + } + + if namespace != "" { + opts.Metricnamespace = &namespace + } + + resp, err := service.metricsClient.List(service.context, resourceId, opts) // check for applied charges before returning any errors if resp.Cost != nil && *resp.Cost != 0 {