webdevops / azure-metrics-exporter

Azure Monitor metrics exporter for Prometheus with dimension support, template engine and ServiceDiscovery
MIT License
118 stars 24 forks source link

Support for `microsoft.resources/subscriptions` at Subscription scope #61

Open gcampbell12 opened 10 months ago

gcampbell12 commented 10 months ago

Querying for https://learn.microsoft.com/en-us/azure/azure-monitor/reference/supported-metrics/microsoft-resources-subscriptions-metrics currently fails due to the default filter passed here https://github.com/webdevops/azure-metrics-exporter/blob/34985800463fedcc311d547cf6bab7999fad1726/metrics/prober.go#L212 This causes azure to throw the following error:

{
  "cost": 0,
  "timespan": "2023-08-28T03:10:27Z/2023-08-28T04:10:27Z",
  "interval": "PT1M",
  "value": [
    {
      "id": "subscriptions/<subid>/providers/Microsoft.Insights/metrics/Traffic",
      "type": "Microsoft.Insights/metrics",
      "name": {
        "value": "Traffic",
        "localizedValue": "Traffic"
      },
      "displayDescription": "Traffic data for all requests to Azure Resource Manager",
      "unit": "Count",
      "timeseries": [],
      "errorMessage": "Metric doesn't have preaggregate defined to be sent to metrics store or cache server which contains requested dimensions and requested sampling types. minMaxRequested:False, percentileRequested:False, DistinctCountColumns: , useExactMatchingPreaggregate:False. Metric:armshoebox47,Requests,Latency, Dimension Names:IsCustomerOriginated|microsoft.resourceid|Microsoft.SubscriptionId, Dimension Filters:[dimensionName:Microsoft.SubscriptionId, dimensionValues:<subid>, isExcludeFilter:False, isRegularExpression:False]|[dimensionName:microsoft.resourceid, dimensionValues:, isExcludeFilter:False, isRegularExpression:False]|[dimensionName:IsCustomerOriginated, dimensionValues:true, isExcludeFilter:False, isRegularExpression:False], OptedInToUseMdmWithoutMetricConfig:False.",
      "errorCode": "InvalidSeries"
    }
  ],
  "namespace": "microsoft.resources/subscriptions",
  "resourceregion": "global"
}

Not sure whats the best option for handling this other than special casing the metric namespace and nulling the filter