azure-resourcemanager-exporter icon indicating copy to clipboard operation
azure-resourcemanager-exporter copied to clipboard

add budget metrics by scope (subscriptions/billing account) and budget forecast metric

Open kevindelmont opened this issue 11 months ago • 2 comments

  • Externalize budget from costs
  • Add the possibility to specify the scope for budget and more specifically billing account. by default, if scope is not specified, it use all subscriptions of the Azure tenant.
  • Add the forecast budget
  budgets:
    scrapeTime: 1h

    # optional, see https://learn.microsoft.com/en-us/rest/api/cost-management/query/usage?tabs=HTTP
    # will disable fetching by subscription and will enable fetching by scope
    #scopes: [...]
    # '/subscriptions/{subscriptionId}/' for subscription scope
    # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope
    # '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope
    # '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope
    # '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope
    # '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope
    # '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile scope
    # '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' for invoiceSection scope
    # '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners

No changes on metrics and labels, just add azurerm_budgets_forecast

# HELP azurerm_budgets_current Azure ResourceManager consumption budget current
# TYPE azurerm_budgets_current gauge
azurerm_budgets_current{budgetName="Azure_Example_Budget",resourceGroup="",resourceID="/subscriptions/<subscription-id>/providers/microsoft.consumption/budgets/Azure_Example_Budget",scope="/subscriptions/<subscription-id>/",subscriptionID="<subscription-id>",unit="eur"} 24.125064975169156
# HELP azurerm_budgets_forecast Azure ResourceManager consumption budget forecast
# TYPE azurerm_budgets_forecast gauge
azurerm_budgets_forecast{budgetName="Azure_Example_Budget",resourceGroup="",resourceID="/subscriptions/<subscription-id>/providers/microsoft.consumption/budgets/Azure_Example_Budget",scope="/subscriptions/<subscription-id>/",subscriptionID="<subscription-id>",unit="eur"} 88.870500129221
# HELP azurerm_budgets_info Azure ResourceManager consumption budget info
# TYPE azurerm_budgets_info gauge
azurerm_budgets_info{budgetName="Azure_Example_Budget",category="cost",resourceGroup="",resourceID="/subscriptions/<subscription-id>/providers/microsoft.consumption/budgets/Azure_Example_Budget",scope="/subscriptions/<subscription-id>/",subscriptionID="<subscription-id>",timeGrain="Monthly"} 1
# HELP azurerm_budgets_limit Azure ResourceManager consumption budget limit
# TYPE azurerm_budgets_limit gauge
azurerm_budgets_limit{budgetName="Azure_Example_Budget",resourceGroup="",resourceID="/subscriptions/<subscription-id>/providers/microsoft.consumption/budgets/Azure_Example_Budget",scope="/subscriptions/<subscription-id>/",subscriptionID="<subscription-id>"} 50
# HELP azurerm_budgets_usage Azure ResourceManager consumption budget usage percentage
# TYPE azurerm_budgets_usage gauge
azurerm_budgets_usage{budgetName="Azure_Example_Budget",resourceGroup="",resourceID="/subscriptions/<subscription-id>/providers/microsoft.consumption/budgets/Azure_Example_Budget",scope="/subscriptions/<subscription-id>/",subscriptionID="<subscription-id>"} 0.4825012995033831

kevindelmont avatar Mar 12 '24 11:03 kevindelmont

Nice feature

  • [X] Test on 1 subscription
  • [X] Test on 1 profile

PaulPowershell avatar Mar 12 '24 11:03 PaulPowershell