Skip to content

[receiver/azuremonitor] "spanTime" for metrics query should be increased #46047

@celian-garcia

Description

@celian-garcia

Component(s)

receiver/azuremonitor

What happened?

Description

When making GET metrics queries to Azure API, being batch mode or not, we specify a "spanTime" which correspond to the timerange of the queried metrics.
Currently the queries are made with following "spanTime" param

  • non batch mode : span time = timegrain (e.g spanTime=PT1M for 1min timegrains)
  • batch mode : span time = 4 * timegrain

It appears that this is not enough for some metrics.

e.g with postgresql metrics #44940, no data after 5min before now for a timegrain of 1min.

cegarcia@NCELRND0473 ~ % az monitor metrics list --resource /subscriptions/<subcription id>/resourceGroups/<resource group>/providers/Microsoft.DBforPostgreSQL/flexibleServers/<name> --metric disk_queue_depth --dimension LogicalServerName --aggregation Average Maximum Minimum
{
  "cost": 177,
  "interval": "PT1M",
  "namespace": "Microsoft.DBforPostgreSQL/flexibleServers",
  "resourceregion": "northeurope",
  "timespan": "2026-02-11T08:45:01Z/2026-02-11T09:45:01Z",
  "value": [
    {
      "displayDescription": "Number of outstanding I/O operations to the data disk",
      "errorCode": "Success",
      "id": "<redacted>",
      "name": {
        "localizedValue": "Disk Queue Depth",
        "value": "disk_queue_depth"
      },
      "resourceGroup": "<redacted>",
      "timeseries": [
        {
          "data": [
            {
              "average": 0.0,
              "maximum": 0.0,
              "minimum": 0.0,
              "timeStamp": "2026-02-11T08:45:00Z"
            },
            [...]
            {
              "average": 0.0,
              "maximum": 0.0,
              "minimum": 0.0,
              "timeStamp": "2026-02-11T09:39:00Z"
            },
            {
              "timeStamp": "2026-02-11T09:40:00Z"
            },
            {
              "timeStamp": "2026-02-11T09:41:00Z"
            },
            {
              "timeStamp": "2026-02-11T09:42:00Z"
            },
            {
              "timeStamp": "2026-02-11T09:43:00Z"
            },
            {
              "timeStamp": "2026-02-11T09:44:00Z"
            }
          ],
          "metadatavalues": [
            {
              "name": {
                "localizedValue": "logicalservername",
                "value": "logicalservername"
              },
              "value": "<redacted>"
            }
          ]
        }
      ],
      "type": "Microsoft.Insights/metrics",
      "unit": "Count"
    }
  ]
}

Steps to Reproduce

...
receivers:
  azuremonitor:
    subscription_ids: [ ... ]
    resource_groups: [ ... ]
    use_batch_api: false # or true
    services:
      - Microsoft.DBforPostgreSQL/flexibleServers
    auth:
      authenticator: azureauth
    metrics:
      "microsoft.dbforpostgresql/flexibleservers":
        disk_queue_depth: [ ]

Expected Result

Expect some metrics, even if the timestamp is more than 5min old in past. (The last Azure API has)

Actual Result

No results.

Collector version

v0.145.0

Environment information

Environment

OS: (e.g., "Ubuntu 20.04")
Compiler(if manually compiled): (e.g., "go 14.2")

OpenTelemetry Collector configuration

Log output

Additional context

No response

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions