usage_monthly_attribution
Creates, updates, deletes, gets or lists a usage_monthly_attribution resource.
Overview
| Name | usage_monthly_attribution |
| Type | Resource |
| Id | datadog.organization.usage_monthly_attribution |
Fields
The following fields are returned by SELECT queries:
- get_monthly_usage_attribution
| Name | Datatype | Description |
|---|---|---|
public_id | string | The organization public ID. |
org_name | string | The name of the organization. |
month | string (date-time) | Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM]. |
region | string | The region of the Datadog instance that the organization belongs to. |
tag_config_source | string | The source of the usage attribution tag configuration and the selected tags in the format <source_org_name>:::<selected tag 1>///<selected tag 2>///<selected tag 3>. |
tags | object | Tag keys and values. A null value here means that the requested tag breakdown cannot be applied because it does not match the [tags configured for usage attribution](https://docs.datadoghq.com/account_management/billing/usage_attribution/#getting-started). In this scenario the API returns the total usage, not broken down by tags. |
updated_at | string (date-time) | Datetime of the most recent update to the usage values. |
values | object | Fields in Usage Summary by tag(s). |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_monthly_usage_attribution | select | start_month, fields | end_month, sort_direction, sort_name, tag_breakdown_keys, next_record_id, include_descendants | Get monthly usage attribution. Multi-region data is available starting March 1, 2023.<br /><br />This API endpoint is paginated. To make sure you receive all records, check if the value of next_record_id is<br />set in the response. If it is, make another request and pass next_record_id as a parameter.<br />Pseudo code example:<br /><br /><br />response := GetMonthlyUsageAttribution(start_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 := GetMonthlyUsageAttribution(start_month, next_record_id=cursor)<br /> cursor := response.metadata.pagination.next_record_id<br />END<br /> |
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.
| Name | Datatype | Description |
|---|---|---|
fields | string | Comma-separated list of usage types to return, or * for all usage types. Usage types are in the format <usage_type>_usage and <usage_type>_percentage. Example: infra_host_usage,infra_host_percentage To obtain the complete list of usage attribution types that can be used to replace <usage_type> in the field names, make a request to the [Get usage attribution types API](https://docs.datadoghq.com/api/latest/usage-metering/#get-usage-attribution-types). |
site | string | The 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. |
start_month | string (date-time) | Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for usage beginning in this month. Maximum of 15 months ago. |
end_month | string (date-time) | Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for usage ending this month. |
include_descendants | boolean | Include child org usage in the response. Defaults to true. |
next_record_id | string | List following results with a next_record_id provided in the previous query. |
sort_direction | string | The direction to sort by: [desc, asc]. |
sort_name | string | The field to sort by. Sort fields are in the format <usage_type>_usage. Example: infra_host_usage To obtain the complete list of usage attribution types that can be used to replace <usage_type> in the field names, make a request to the [Get usage attribution types API](https://docs.datadoghq.com/api/latest/usage-metering/#get-usage-attribution-types). |
tag_breakdown_keys | string | Comma separated list of tag keys used to group usage. If no value is provided the usage 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_usage_attribution
Get monthly usage attribution. Multi-region data is available starting March 1, 2023.<br /><br />This API endpoint is paginated. To make sure you receive all records, check if the value of next_record_id is<br />set in the response. If it is, make another request and pass next_record_id as a parameter.<br />Pseudo code example:<br /><br /><br />response := GetMonthlyUsageAttribution(start_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 := GetMonthlyUsageAttribution(start_month, next_record_id=cursor)<br /> cursor := response.metadata.pagination.next_record_id<br />END<br />
SELECT
public_id,
org_name,
month,
region,
tag_config_source,
tags,
updated_at,
values
FROM datadog.organization.usage_monthly_attribution
WHERE start_month = '{{ start_month }}' -- required
AND fields = '{{ fields }}' -- 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 }}'
;