Migrating from the V1 Hourly Usage APIs to V2
Summary
On February 1, 2025, the individual hourly usage by product endpoints will be deprecated in favor of the v2 hourly usage by product family API.
Users of the v1 APIs should recognize familiar concepts in the consolidated v2 hourly usage API,
just represented in a slightly different format.
The most notable differences between the v1 API and the v2 API are that the v2 API:
- Consolidates all products to one endpoint
- Follows the JSON:API standard
- Is paginated
- Can return data for multiple organizations and regions per request
Each difference is discussed in further detail in the following sections.
Consolidated Product Families
The v2 API introduces the concepts of product family and usage type. Product families are
groupings of one or more usage types. Usage types are usage measurements for a given organization
and time period. The all product family retrieves the usage for all product families or you can filter by specific product families.
This list below shows how the product families and usage types map to the v1 hourly usage endpoints. Usage type and datapoint are the same, except where explicitly noted:
- ENDPOINT | PRODUCT FAMILY
<base_url>/api/v1/usage/hosts | infra_hostsagent_host_countalibaba_host_countapm_azure_app_service_host_countapm_host_countaws_host_countazure_host_countcontainer_countgcp_host_countheroku_host_counthost_countinfra_azure_app_serviceopentelemetry_host_countvsphere_host_count<base_url>/api/v1/usage/logs | logsbillable_ingested_bytesindexed_events_countingested_events_byteslogs_live_indexed_countlogs_live_ingested_byteslogs_rehydrated_indexed_countlogs_rehydrated_ingested_bytes<base_url>/api/v1/usage/timeseries | timeseriesnum_custom_input_timeseriesnum_custom_output_timeseriesnum_custom_timeseries<base_url>/api/v1/usage/indexed-spans | indexed_spansindexed_events_count<base_url>/api/v1/usage/synthetics- Deprecated. See synthetics_api and synthetics_browser for synthetics usage
<base_url>/api/v1/usage/synthetics_api | synthetics_apicheck_calls_count<base_url>/api/v1/usage/synthetics_browser | synthetics_browserbrowser_check_calls_count<base_url>/api/v1/usage/fargate | fargateavg_profiled_fargate_taskstasks_count<base_url>/api/v1/usage/aws_lambda | serverlessfunc_countinvocations_sum<base_url>/api/v1/usage/rum_sessions | rum- See RUM Migration Guide for full mapping instructions.
<base_url>/api/v1/usage/network_hosts | network_hostshost_count<base_url>/api/v1/usage/network_flows | network_flowsindexed_events_count<base_url>/api/v1/usage/logs-by-retention | indexed_logs- Note: The usage type and datapoint are separate for this URL, because the retention value is included in the usage type.
- Usage Type:
logs_indexed_events_<retention>_count Datapoint: indexed_events_count - Usage Type:
logs_live_indexed_events_<retention>_count Datapoint: live_indexed_events_count - Usage Type:
logs_rehydrated_indexed_events_<retention>_count Datapoint: rehydrated_indexed_events_count - Usage Type: In
usage_type, replace <retention> with one of : 3_day, 7_day, 15_day, 30_day, 45_day, 60_day, 90_day, 180_day, 365_day, custom Datapoint: retention <base_url>/api/v1/usage/analyzed_logs | analyzed_logsanalyzed_logs<base_url>/api/v1/usage/snmp | snmpsnmp_devices<base_url>/api/v1/usage/profiling | profilinghost_count<base_url>/api/v1/usage/ingested-spans | ingested_spansingested_events_bytes<base_url>/api/v1/usage/incident-management | incident_managementmonthly_active_users<base_url>/api/v1/usage/iot | iotiot_device_count<base_url>/api/v1/usage/cspm | cspmaas_host_countazure_host_countcompliance_host_countcontainer_counthost_count<base_url>/api/v1/usage/cws | cwscws_container_countcws_host_count<base_url>/api/v1/usage/dbm | dbmdbm_host_countdbm_queries_count<base_url>/api/v1/usage/sds | sdslogs_scanned_bytestotal_scanned_bytes<base_url>/api/v1/usage/ci-app | ci_appci_pipeline_indexed_spansci_test_indexed_spansci_visibility_pipeline_committersci_visibility_test_committers<base_url>/api/v1/usage/online-archive | online_archiveonline_archive_events_count<base_url>/api/v2/usage/lambda_traced_invocations | lambda_traced_invocationslambda_traced_invocations_count<base_url>/api/v2/usage/application_security | application_securityapp_sec_host_count<base_url>/api/v2/usage/observability_pipelines | observability_pipelinesobservability_pipelines_bytes_processed
Response bodies and parameter names conform to the JSON:API specification. All data
available in the v1 APIs is still available. See the example below of the mapping from the v1 hosts
API to the v2 hourly usage API.
V1 API: Get hourly usage for hosts and containers
Request
https://api.datadoghq.com/api/v1/usage/hosts?start_hr=2022-06-01T00&end_hr=2022-06-01T01
Notes
- Product is an element of the path
hosts. - Time bounds are controlled by the parameters
start_hr and end_hr.
Response
{
"usage": [
{
"agent_host_count": 1,
"alibaba_host_count": 2,
"apm_azure_app_service_host_count": 3,
"apm_host_count": 4,
"aws_host_count": 5,
"azure_host_count": 6,
"container_count": 7,
"gcp_host_count": 8,
"heroku_host_count": 9,
"host_count": 10,
"infra_azure_app_service": 11,
"opentelemetry_host_count": 12,
"vsphere_host_count": 13,
"hour": "2022-06-01T00",
"org_name": "Customer Inc",
"public_id": "abc123"
}
]
}
Notes
- Usage for each hour is represented as an object in the usage array.
- Usage types are keys in the object, and measured usage for those usage types are the corresponding values.
- Hour, organization name, and public ID are also fields in the object.
V2 API: Get hourly usage by product family
Request
https://api.datadoghq.com/api/v2/usage/hourly_usage?filter[timestamp][start]=2022-06-01T00&filter[timestamp][end]=2022-06-01T01&filter[product_families]=infra_hosts
Notes
- Product is passed as a query parameter
filter[product_families]=infra_hosts. - Time bounds are controlled by the parameters
filter[timestamp][start] and filter[timestamp][end].
Response
{
"data": [
{
"attributes": {
"org_name": "Customer Inc",
"public_id": "abc123",
"timestamp": "2022-06-01T00:00:00+00:00",
"region": "us",
"measurements": [
{
"usage_type": "agent_host_count",
"value": 1
},
{
"usage_type": "alibaba_host_count",
"value": 2
},
{
"usage_type": "apm_azure_app_service_host_count",
"value": 3
},
{
"usage_type": "apm_host_count",
"value": 4
},
{
"usage_type": "aws_host_count",
"value": 5
},
{
"usage_type": "azure_host_count",
"value": 6
},
{
"usage_type": "container_count",
"value": 7
},
{
"usage_type": "gcp_host_count",
"value": 8
},
{
"usage_type": "heroku_host_count",
"value": 9
},
{
"usage_type": "host_count",
"value": 10
},
{
"usage_type": "infra_azure_app_service",
"value": 11
},
{
"usage_type": "opentelemetry_host_count",
"value": 12
},
{
"usage_type": "vsphere_host_count",
"value": 13
}
],
"product_family": "infra_hosts"
},
"type": "usage_timeseries",
"id": "ec3e0318b98d15c2ae8125e8bda0ff487cd08d80b120fb340c9322ee16f28629"
}
]
}
Notes
- Objects in the data array represent hourly usage, for each product and each organization.
- V1 APIs did not support multiple products or multiple organizations per request.
- Usage measurements are represented in the nested
measurements array. - Usage measurement objects have the fields
usage_type and value. hour, org_name, and public_id are also fields in the attributes object.
The v2 hourly usage API is paginated. Responses are limited to 500 pages, with a page containing usage data for one
product family, for one hour, for one organization. Pagination allows the API to support other features such as multiple
products per request, multiple organizations per request, and unlimited time ranges.
If a result has more pages, the record ID of the next page is returned in the field
meta.pagination.next_record_id. Clients should then pass that id in the parameter pagination[next_record_id]. There
are no more pages to retrieve when the meta.pagination.next_record_id field is not set.
Code example
response := GetHourlyUsage(start_time, end_time, product_families)
cursor := response.metadata.pagination.next_record_id
WHILE cursor != null BEGIN
sleep(5 seconds) # Avoid running into rate limit
response := GetHourlyUsage(start_time, end_time, product_families, next_record_id=cursor)
cursor := response.metadata.pagination.next_record_id
END
Multi-organization responses
The v2 API supports retrieving usage data for all of your child organizations in all regions in one request. Use the
parameter filter[include_descendants] to request data for child organizations.
Further Reading
Additional helpful documentation, links, and articles: