[Azure monitor] ignore_unsupported does not skip HTTP 400 for unsupported metric namespaces
Summary
ignore_unsupported: true should skip a resource when its namespace is not a supported Azure Monitor platform metric namespace. Today a HTTP 400 from the metricDefinitions API is still fatal. The azure.monitor metricset returns the error. The Elastic Agent unit changes from HEALTHY to DEGRADED. Collection stops for every resource in that unit, including types that are valid.
This is the Beats defect behind elastic/integrations#20848.
Version
- Elastic Stack 9.5.2
- Elastic Agent 9.4.4
- Azure Resource Metrics integration 1.14.0
- Current
mainstill has the same path inx-pack/metricbeat/module/azure
Operating System
Linux (AKS). The failure is in the Azure Monitor API client, not in the OS.
Expected behaviour
When ignore_unsupported is true and Azure returns HTTP 400 because the namespace is not a supported platform metric namespace:
- Metricbeat logs an info or warning line.
- Metricbeat skips that resource.
- Metricbeat continues collection for the other resources in the same cycle.
- The unit stays
HEALTHY.
That is the documented purpose of ignore_unsupported on MetricConfig.
Actual behaviour
GetMetricDefinitionsWithRetry returns the HTTP 400. mapMetrics returns that error before it reads IgnoreUnsupported. InitResources then fails the whole refresh. The Agent unit becomes DEGRADED.
ignore_unsupported only applies after a successful definitions call that returns an empty list. It does not apply to a 400 from Azure.
Example error:
Error fetching data for metricset azure.monitor: GET https://management.azure.com/subscriptions/<id>/resourceGroups/<rg>/providers/Microsoft.Insights/activityLogAlerts/<name>/providers/Microsoft.Insights/metricDefinitions
RESPONSE 400: 400 Bad Request
ERROR CODE: BadRequest
{
"code": "BadRequest",
"message": "Microsoft.Insights/activityLogAlerts is not a supported platform metric namespace, ..."
}Unit state: HEALTHY to DEGRADED.
Affected code
1. HTTP 400 is fatal before ignore_unsupported is checked
GetMetricDefinitionsWithRetry returns on error before IgnoreUnsupported is checked:
- Sequential:
- Concurrent:
ignore_unsupported is only used later, when the call succeeds and the list is empty:
- Sequential:
- Concurrent:
2. Non-429 errors are always returned
GetMetricDefinitionsWithRetry and sleepIfPossible retry HTTP 429 only. HTTP 400 is returned as an error.
3. One mapping error fails the whole unit
InitResources returns on the first mapMetrics error. Remaining resource configs are not processed.
Source: elastic/beats