Skip to main content

budgets

Creates, updates, deletes, gets or lists a budgets resource.

Overview

Namebudgets
TypeResource
Iddatadog.cloud_costs.budgets

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe BudgetWithEntriesData id. (example: 00000000-0a0a-0a0a-aaa0-00000000000a)
attributesobjectThe attributes of a budget.
typestringThe type of the object, must be budget. (example: )

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_budgetselectbudget_idactual, forecast, start, endGet a budget by ID. Pass actual=true or forecast=true to include cost data in the response. Use start and end (millisecond epochs, both required) to set the cost window. When forecast=true, each entry also includes ootb_forecast (the ML forecast before overrides) and custom_forecast (null if no override is set, a number if one is).
list_budgetsselectList budgets.
upsert_budgetreplaceCreate a new budget or update an existing one.
delete_budgetdeletebudget_idDelete a budget
validate_budgetexecValidate a budget configuration without creating or modifying it

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
budget_idstringBudget id.
sitestringThe Datadog site (region) for your organization, for example datadoghq.com, us3.datadoghq.com, us5.datadoghq.com, ap1.datadoghq.com, ap2.datadoghq.com, datadoghq.eu, ddog-gov.com. Resolved from the DD_SITE environment variable when set. Optional: defaults to datadoghq.com, or the value of the DD_SITE environment variable when set; a WHERE value overrides both.
actualbooleanWhen true, includes actual cost data in the response.
endinteger (int64)End of the cost window in milliseconds since epoch. Must be used together with start.
forecastbooleanWhen true, includes forecast cost data in the response, including ootb_forecast and custom_forecast per entry.
startinteger (int64)Start of the cost window in milliseconds since epoch. Must be used together with end.

SELECT examples

Get a budget by ID. Pass actual=true or forecast=true to include cost data in the response. Use start and end (millisecond epochs, both required) to set the cost window. When forecast=true, each entry also includes ootb_forecast (the ML forecast before overrides) and custom_forecast (null if no override is set, a number if one is).

SELECT
id,
attributes,
type
FROM datadog.cloud_costs.budgets
WHERE budget_id = '{{ budget_id }}' -- required
AND actual = '{{ actual }}'
AND forecast = '{{ forecast }}'
AND start = '{{ start }}'
AND end = '{{ end }}'
;

REPLACE examples

Create a new budget or update an existing one.

REPLACE datadog.cloud_costs.budgets
SET
data = '{{ data }}'
WHERE
RETURNING
data;

DELETE examples

Delete a budget

DELETE FROM datadog.cloud_costs.budgets
WHERE budget_id = '{{ budget_id }}' --required
;

Lifecycle Methods

EXEC variables use wire (API) names.

Validate a budget configuration without creating or modifying it

EXEC datadog.cloud_costs.budgets.validate_budget
@@json=
'{
"data": "{{ data }}"
}'
;