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

Question: is it possible to filter metrics by resource type and resource tags using the list probe endpoint ? #51

Closed mbenabda closed 1 year ago

mbenabda commented 1 year ago

Hi there. First, let me thank you for the awesome work you're doing providing this exporter.

I'd like to know if there's any way i can filter metrics using both resource type and resource tags ? I'm pretty new to Azure metrics, so this may be straightforward, but i can't figure out how to do this

What i've tried so far:

here's my scraping configuration:

    interval: 1m
    path: /probe/metrics/list
    # https://github.com/webdevops/azure-metrics-exporter#probemetricslist-parameters
    params:
      subscription: ["${subscription_id}"]
      template: ["{name}_{metric}_{aggregation}"]
      name: ["azure_eventhub_namespaces"]
      #resourceType: ["Microsoft.EventHub/Namespaces"] # => works
      #filter: ["tagName eq 'env' AND tagValue eq '${env}'"] # => works
      #filter: ["resourceType eq 'Microsoft.EventHub/Namespaces'"] # => works
      #filter: ["tagName eq 'env' AND tagValue eq '${env}' and resourceType eq 'Microsoft.EventHub/Namespaces'"] # does not work
      filter: ["substringof('${env}',tagName) and resourceType eq 'Microsoft.EventHub/Namespaces'"] # does not work
      metric: 
      - ActiveConnections
      - IncomingMessages
      - OutgoingMessages
      aggregation:
      - total

any help appreciated, thank you !

mbenabda commented 1 year ago

i figured out from https://github.com/Azure/azure-rest-api-specs/issues/21324 that this is actually expected behaviour (even though it is counter intuitive)

the only way I found so far to achieve similar results to what i was looking for is to filter on resource name: resourceType eq 'Microsoft.EventHub/Namespaces' and (substringof('${env}-', name) or substringof('-${env}', name))