webdevops / azure-resourcemanager-exporter

Prometheus exporter for Azure ResourceManager informations (infos, quotas, limits, usages, public IPs, portscanner)
MIT License
33 stars 17 forks source link

Is there a way we configure a custom metric? #38

Closed theok-nice closed 1 year ago

theok-nice commented 1 year ago

In azure rest API you have the option to extract creation and change time of an azure resource

az rest \
    --method GET \
    --url "https://management.azure.com/subscriptions/{subscription-id}/resources" \
    --url-parameters api-version=2020-06-01 \$expand=createdTime \$select=name,createdTime

Is there a way to configure azure-resourcemanager-exporter to create a new metric that will have as value the create time of the resource?

Say you can configure the new metric to have the same labels as azurerm_resource_info metric and as value the creation date of the resource. In order to not return the date for all resources, you could also specify in the config the resources that you are interested (for example the name of the azure providers:disks, virtualmachines, managedclusters etc).

The goal is to be able to sort resources according to creation date in prometheus. When we have the creation date as label of the metric, you can't really filter with an expression like, give me all VMs that are older that one month old.

mblaschke commented 1 year ago

could you use resourcegraph queries for such use-cases? then you can use https://github.com/webdevops/azure-resourcegraph-exporter

theok-nice commented 1 year ago

Thank you for the suggestion. I will give it a try.