Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

kevindelmont
Copy link
Contributor

  • 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

@PaulPowershell
Copy link
Contributor

Nice feature

  • Test on 1 subscription
  • Test on 1 profile

Copy link

sonarcloud bot commented Mar 12, 2024

Quality Gate Passed Quality Gate passed

Issues
2 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants