webdevops / azure-metrics-exporter

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

Is it possible to specify the subscription and resource group in the azure-metrics-exporter config instead of Prometheus? #79

Open johnswarbrick-napier opened 7 months ago

johnswarbrick-napier commented 7 months ago

I have two related issues:

(1) I want to specify the Azure subscription as an environment variable that is passed automatically to azure-metrics-exporter instead of specifying it manually in the Prometheus scrape config;

(2) I want to specify the resource group as an environment variable that is password automatically to azure-metrics-monitor so the results are always filtered to the given resource group name;

I tried passing the subscription ID from a Kubernetes secret already, but it seems I still need to specify the subscription ID in the Prometheus scape config?

   - name: AZURE_SERVICEDISCOVERY_SUBSCRIPTION_ID
     valueFrom:
       secretKeyRef:
         key: subscription
         name: azure-resource-details
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Mon, 26 Feb 2024 17:37:01 GMT
Content-Length: 36

parameter "subscription" is missing

And there doesn't seem to be any method of specifying the resource group as an environment variable at all in the docs?

The reason is that I am currently using an identical Prometheus scraping configuration across more than 100 clusters, and I don't want to manually specify the subscription ID or resource group individually within each cluster.

And I need to filter by resource group to prevent azure-metrics-exporter from returning metrics for a resource group that I don't want reporting into Grafana.

These are the startup logs:

image

Thanks :)

johnswarbrick-napier commented 5 months ago

Hi - any thoughts on this at all?

davejhahn commented 5 months ago

@johnswarbrick-napier

        params:
          name: ["my-name"]
          subscription:
          - <subscriptionId>
          filter: ["(resourceGroup eq '<rg_name>' or resourceGroup eq '<rg_name>') and resourceType eq '<res_type>'"]

I'm just trying to figure out how to do the same for resource name. There are resources in Azure that have different metrics depending on the implementation, e.g. Cognitive Services, and the metrics available are different, so trying to filter by name.