Skip to main content

monthly_cost_attribution

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

Overview

Namemonthly_cost_attribution
TypeResource
Iddatadog.cloud_costs.monthly_cost_attribution

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringUnique ID of the response.
attributesobjectCost Attribution by Tag for a given organization.
typestringType of cost attribution data. (default: cost_by_tag, example: cost_by_tag)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_monthly_cost_attributionselectstart_month, fields, regionend_month, sort_direction, sort_name, tag_breakdown_keys, next_record_id, include_descendantsGet monthly cost attribution by tag across multi-org and single root-org accounts.
Cost Attribution data for a given month becomes available no later than the 19th of the following month.
This API endpoint is paginated. To make sure you receive all records, check if the value of next_record_id is
set in the response. If it is, make another request and pass next_record_id as a parameter.
Pseudo code example:
<br />response := GetMonthlyCostAttribution(start_month, end_month)<br />cursor := response.metadata.pagination.next_record_id<br />WHILE cursor != null BEGIN<br /> sleep(5 seconds) # Avoid running into rate limit<br /> response := GetMonthlyCostAttribution(start_month, end_month, next_record_id=cursor)<br /> cursor := response.metadata.pagination.next_record_id<br />END<br />

This endpoint is only accessible for parent-level organizations. This endpoint is not available in the Government (US1-FED) site.

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
fieldsstringComma-separated list specifying cost types (e.g., <billing_dimension>_on_demand_cost, <billing_dimension>_committed_cost, <billing_dimension>_total_cost) and the proportions (<billing_dimension>_percentage_in_org, <billing_dimension>_percentage_in_account). Use * to retrieve all fields. Example: infra_host_on_demand_cost,infra_host_percentage_in_account To obtain the complete list of active billing dimensions that can be used to replace <billing_dimension> in the field names, make a request to the Get active billing dimensions API.
regionstring(default: datadoghq.com)
start_monthstring (date-time)Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for cost beginning in this month.
end_monthstring (date-time)Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for cost ending this month.
include_descendantsbooleanInclude child org cost in the response. Defaults to true.
next_record_idstringList following results with a next_record_id provided in the previous query.
sort_directionstringThe direction to sort by: [desc, asc].
sort_namestringThe billing dimension to sort by. Always sorted by total cost. Example: infra_host.
tag_breakdown_keysstringComma separated list of tag keys used to group cost. If no value is provided the cost will not be broken down by tags. To see which tags are available, look for the value of tag_config_source in the API response.

SELECT examples

Get monthly cost attribution by tag across multi-org and single root-org accounts.
Cost Attribution data for a given month becomes available no later than the 19th of the following month.
This API endpoint is paginated. To make sure you receive all records, check if the value of next_record_id is
set in the response. If it is, make another request and pass next_record_id as a parameter.
Pseudo code example:
<br />response := GetMonthlyCostAttribution(start_month, end_month)<br />cursor := response.metadata.pagination.next_record_id<br />WHILE cursor != null BEGIN<br /> sleep(5 seconds) # Avoid running into rate limit<br /> response := GetMonthlyCostAttribution(start_month, end_month, next_record_id=cursor)<br /> cursor := response.metadata.pagination.next_record_id<br />END<br />

This endpoint is only accessible for parent-level organizations. This endpoint is not available in the Government (US1-FED) site.

SELECT
id,
attributes,
type
FROM datadog.cloud_costs.monthly_cost_attribution
WHERE start_month = '{{ start_month }}' -- required
AND fields = '{{ fields }}' -- required
AND region = '{{ region }}' -- required
AND end_month = '{{ end_month }}'
AND sort_direction = '{{ sort_direction }}'
AND sort_name = '{{ sort_name }}'
AND tag_breakdown_keys = '{{ tag_breakdown_keys }}'
AND next_record_id = '{{ next_record_id }}'
AND include_descendants = '{{ include_descendants }}'
;