Skip to main content

arbitrary_rules

Creates, updates, deletes, gets or lists an arbitrary_rules resource.

Overview

Namearbitrary_rules
TypeResource
Iddatadog.cloud_costs.arbitrary_rules

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe ArbitraryRuleResponseData id.
attributesobjectThe definition of ArbitraryRuleResponseDataAttributes object.
typestringArbitrary rule resource type. (arbitrary_rule) (default: arbitrary_rule, example: arbitrary_rule)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_custom_allocation_ruleselectrule_idGet a specific custom allocation rule - Retrieve a specific custom allocation rule by its ID
list_custom_allocation_rulesselectList all custom allocation rules - Retrieve a list of all custom allocation rules for the organization
create_custom_allocation_ruleinsertCreate a new custom allocation rule with the specified filters and allocation strategy.<br /><br />Strategy Methods:<br />- PROPORTIONAL/EVEN: Allocates costs proportionally/evenly based on existing costs. Requires: granularity, allocated_by_tag_keys. Optional: based_on_costs, allocated_by_filters, evaluate_grouped_by_tag_keys, evaluate_grouped_by_filters.<br />- PROPORTIONAL_TIMESERIES/EVEN_TIMESERIES: Allocates based on timeseries data. Requires: granularity, based_on_timeseries. Optional: evaluate_grouped_by_tag_keys.<br />- PERCENT: Allocates fixed percentages to specific tags. Requires: allocated_by (array of percentage allocations).<br /><br />Filter Conditions:<br />- Use value for single-value conditions: "is", "is not", "contains", "=", "!=", "like", "not like"<br />- Use values for multi-value conditions: "in", "not in"<br />- Cannot use both value and values simultaneously.<br /><br />Supported operators: is, is not, contains, in, not in, =, !=, like, not like
update_custom_allocation_ruleupdaterule_idUpdate an existing custom allocation rule with new filters and allocation strategy.<br /><br />Strategy Methods:<br />- PROPORTIONAL/EVEN: Allocates costs proportionally/evenly based on existing costs. Requires: granularity, allocated_by_tag_keys. Optional: based_on_costs, allocated_by_filters, evaluate_grouped_by_tag_keys, evaluate_grouped_by_filters.<br />- PROPORTIONAL_TIMESERIES/EVEN_TIMESERIES: Allocates based on timeseries data. Requires: granularity, based_on_timeseries. Optional: evaluate_grouped_by_tag_keys.<br />- PERCENT: Allocates fixed percentages to specific tags. Requires: allocated_by (array of percentage allocations).<br />- USAGE_METRIC: Allocates based on usage metrics (implementation varies).<br /><br />Filter Conditions:<br />- Use value for single-value conditions: "is", "is not", "contains", "=", "!=", "like", "not like"<br />- Use values for multi-value conditions: "in", "not in"<br />- Cannot use both value and values simultaneously.<br /><br />Supported operators: is, is not, contains, in, not in, =, !=, like, not like
delete_custom_allocation_ruledeleterule_idDelete a custom allocation rule - Delete an existing custom allocation rule by its ID
reorder_custom_allocation_rulesexecdataReorder custom allocation rules - Change the execution order of custom allocation rules.<br /><br />Important: You must provide the complete list of all rule IDs in the desired execution order. The API will reorder ALL rules according to the provided sequence.<br /><br />Rules are executed in the order specified, with lower indices (earlier in the array) having higher priority.<br /><br />Example: If you have rules with IDs [123, 456, 789] and want to change order from 123→456→789 to 456→123→789, send: [{"id": "456"}, {"id": "123"}, {"id": "789"}]

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
rule_idinteger (int64)The unique identifier of the custom allocation rule
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.

SELECT examples

Get a specific custom allocation rule - Retrieve a specific custom allocation rule by its ID

SELECT
id,
attributes,
type
FROM datadog.cloud_costs.arbitrary_rules
WHERE rule_id = '{{ rule_id }}' -- required
;

INSERT examples

Create a new custom allocation rule with the specified filters and allocation strategy.<br /><br />Strategy Methods:<br />- PROPORTIONAL/EVEN: Allocates costs proportionally/evenly based on existing costs. Requires: granularity, allocated_by_tag_keys. Optional: based_on_costs, allocated_by_filters, evaluate_grouped_by_tag_keys, evaluate_grouped_by_filters.<br />- PROPORTIONAL_TIMESERIES/EVEN_TIMESERIES: Allocates based on timeseries data. Requires: granularity, based_on_timeseries. Optional: evaluate_grouped_by_tag_keys.<br />- PERCENT: Allocates fixed percentages to specific tags. Requires: allocated_by (array of percentage allocations).<br /><br />Filter Conditions:<br />- Use value for single-value conditions: "is", "is not", "contains", "=", "!=", "like", "not like"<br />- Use values for multi-value conditions: "in", "not in"<br />- Cannot use both value and values simultaneously.<br /><br />Supported operators: is, is not, contains, in, not in, =, !=, like, not like

INSERT INTO datadog.cloud_costs.arbitrary_rules (
data
)
SELECT
'{{ data }}'
RETURNING
data
;

UPDATE examples

Update an existing custom allocation rule with new filters and allocation strategy.<br /><br />Strategy Methods:<br />- PROPORTIONAL/EVEN: Allocates costs proportionally/evenly based on existing costs. Requires: granularity, allocated_by_tag_keys. Optional: based_on_costs, allocated_by_filters, evaluate_grouped_by_tag_keys, evaluate_grouped_by_filters.<br />- PROPORTIONAL_TIMESERIES/EVEN_TIMESERIES: Allocates based on timeseries data. Requires: granularity, based_on_timeseries. Optional: evaluate_grouped_by_tag_keys.<br />- PERCENT: Allocates fixed percentages to specific tags. Requires: allocated_by (array of percentage allocations).<br />- USAGE_METRIC: Allocates based on usage metrics (implementation varies).<br /><br />Filter Conditions:<br />- Use value for single-value conditions: "is", "is not", "contains", "=", "!=", "like", "not like"<br />- Use values for multi-value conditions: "in", "not in"<br />- Cannot use both value and values simultaneously.<br /><br />Supported operators: is, is not, contains, in, not in, =, !=, like, not like

UPDATE datadog.cloud_costs.arbitrary_rules
SET
data = '{{ data }}'
WHERE
rule_id = '{{ rule_id }}' --required
RETURNING
data;

DELETE examples

Delete a custom allocation rule - Delete an existing custom allocation rule by its ID

DELETE FROM datadog.cloud_costs.arbitrary_rules
WHERE rule_id = '{{ rule_id }}' --required
;

Lifecycle Methods

EXEC variables use wire (API) names.

Reorder custom allocation rules - Change the execution order of custom allocation rules.<br /><br />Important: You must provide the complete list of all rule IDs in the desired execution order. The API will reorder ALL rules according to the provided sequence.<br /><br />Rules are executed in the order specified, with lower indices (earlier in the array) having higher priority.<br /><br />Example: If you have rules with IDs [123, 456, 789] and want to change order from 123→456→789 to 456→123→789, send: [{"id": "456"}, {"id": "123"}, {"id": "789"}]

EXEC datadog.cloud_costs.arbitrary_rules.reorder_custom_allocation_rules
@@json=
'{
"data": "{{ data }}"
}'
;