elastic / beats

:tropical_fish: Beats - Lightweight shippers for Elasticsearch & Logstash
https://www.elastic.co/products/beats
Other
108 stars 4.93k forks source link

Error fetching data for metricset azure.monitor #41478

Open TomonoriSoejima opened 3 weeks ago

TomonoriSoejima commented 3 weeks ago

From Azure logs integration, we are seeing this error.

[m3:logs]$ sed -n 1253p elastic-agent-8.13.4-a2e31a/elastic-agent-20241029-3.ndjson | jq
{
  "log.level": "error",
  "@timestamp": "2024-10-29T19:09:33.266Z",
  "message": "Error fetching data for metricset azure.monitor: GET https://management.azure.com/subscriptions/f6deb90e-2ff2-40f1-928b-6da308f4f325/resourceGroups/rg-USW2/providers/Microsoft.Sql/servers/sql-kbctrust-us-001/databases/IdentityServer/providers/Microsoft.Insights/metricDefinitions\n--------------------------------------------------------------------------------\nRESPONSE 400: 400 Bad Request\nERROR CODE: BadRequest\n--------------------------------------------------------------------------------\n{\n  \"code\": \"BadRequest\",\n  \"message\": \"Detect invalid value: Microsoft.DocumentDb/databaseAccounts for query parameter: 'metricnamespace', the value must be: Microsoft.Sql/servers/databases if the query parameter is provided, you can also skip this optional query parameter.\"\n}\n--------------------------------------------------------------------------------\n",
  "component": {
    "binary": "metricbeat",
    "dataset": "elastic_agent.metricbeat",
    "id": "azure/metrics-default",
    "type": "azure/metrics"
  },
  "log": {
    "source": "azure/metrics-default"
  },
  "log.origin": {
    "file.line": 256,
    "file.name": "module/wrapper.go",
    "function": "github.com/elastic/beats/v7/metricbeat/mb/module.(*metricSetWrapper).fetch"
  },
  "service.name": "metricbeat",
  "ecs.version": "1.6.0"
}

The error message indicates that the metricnamespace parameter in your Azure Monitor API call is set incorrectly. Specifically, the error message suggests that the metricnamespace should be set to Microsoft.Sql/servers/databases instead of Microsoft.DocumentDb/databaseAccounts when querying metrics for an SQL database.

In https://github.com/elastic/beats/blob/e20e486ad8b74653814c515691c4a5a981f5fd64/x-pack/metricbeat/module/azure/database_account/_meta/data.json#L17, I can see Microsoft.DocumentDb/databaseAccounts and they all need to be replaced with Microsoft.Sql/servers/databases.

botelastic[bot] commented 3 weeks ago

This issue doesn't have a Team:<team> label.