Budget API
The Budget API allows you to create, update, and delete recurring budget rules to control your Kubernetes spending. Weekly and monthly budgets can be established on namespaces, clusters, and labels to set limits on cost spend, with the option to configure alerts for reaching specified budget thresholds via email, Slack, or Microsoft Teams.
Set recurring budget rule or update existing rule
POST
http://<your-kubecost-address>/model/budget
Creates a recurring budget rule or updates a recurring budget rule when provided the ID of the existing rule.
Request Body
Name | Type | Description |
---|---|---|
name* | string | Name of the budget rule |
values* | string | Used for specifying the group and name where the budget rule is applied to in the form of a key-value pair. Accepts |
interval* | string | The interval that the budget will reset with (either |
intervalDay | int | The day the budget will reset. When |
spendLimit* | int | The budget limit value. Currency can be configured in Settings > Cloud Cost Settings > Currency dropdown. |
id | string | Only should be used when updating a budget rule; ID of the budget rule being modified. For more info, see the Using the |
action | string | Optional configurations for providing visibility when your budget exceeds a specified percentage threshold. This parameter can generate emails, and Slack or Microsoft Teams messages to suit your work environment. For more information, see the Using Budget Actions section below. |
Get recurring budget rule(s)
GET
http://<your-kubecost-address>/model/budgets
Lists all existing recurring budget rules
Delete recurring budget rule
DELETE
https://<your-kubecost-address>/model/deleteBudget
Deletes a budget rule defined by id
Path Parameters
Name | Type | Description |
---|---|---|
id* | string | ID of the recurring budget rule to be deleted |
Formatting parameters when creating/updating budget rules
Creating and updating recurring budget rules uses POST requests, which will require submitting a JSON object in the body of your request instead of adding parameters directly into the path (such as when deleting a recurring budget rule). See the Examples section below for more information on formatting your requests.
Using the id
parameter
id
parameterThe id
parameter when using the endpoint /budget
is considered optional, but its use will vary depending on whether you want to create or update a budget rule.
When creating a new budget rule, id
should not be used. An ID for the budget rule will then be randomly generated in the response. When updating an existing budget rule, id
needs to be used to identify which budget rule you want to modify, even if you only have one existing rule.
The id
value of your recurring budget is needed to update or delete it. If you don't have the id
value saved, you can retrieve it using /budgets
, which will generate all existing budgets and their respective id
values.
Using Budget Actions
You can configure greater visibility towards tracking your budgets using the actions
parameter, which will allow you to create alerts for when your budget spend has passed a specified percentage threshold, and send those alerts to you or your team via email, Slack, or Microsoft Teams.
When providing values for actions
, percentage
refers to the percentage of spendLimit
which will result in an alert. For example, if "spendLimit": 2000
is configured for a weekly budget rule and "percentage": 50
is configured, an alert will be sent to all listed emails/webhooks if spending surpasses $1000 USD for the week.
Configuring currency
The spendLimit
parameter will always be determined using your configured currency type. You can manually change your currency type in Kubecost by selecting Settings, then scrolling to Currency and selecting your desired currency from the dropdown (remember to confirm your choice by selecting Save at the bottom of the page).
Kubecost does not convert spending costs to other currency types; it will only change the symbol displayed in the UI next to costs. For best results, configure your currency to what matches your spend.
Examples
Create a recurring budget rule for my test cluster which resets every Wednesday with a budget of $100.00 USD, and will send an alert via email when spending has exceeded 75% of the spend limit.
Create a recurring budget rule for my kubecost
namespace which resets on the 1st of every month with a budget of $400.00 USD, and will send an alert via Slack and Microsoft Teams when spending has exceeded $100.00 of the spend limit.
Last updated