Get all custom metrics by hourly average. Use the month parameter to get a month-to-date data resolution or use the day parameter to get a daily resolution. One of the two is required, and only one of the two is allowed.
This endpoint requires the usage_read permission.
OAuth apps require the usage_read authorization scope to access this endpoint.
Arguments
Query Strings
Name
Type
Description
month
string
Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for usage beginning at this hour. (Either month or day should be specified, but not both)
day
string
Datetime in ISO-8601 format, UTC, precise to day: [YYYY-MM-DD] for usage beginning at this hour. (Either month or day should be specified, but not both)
names
array
Comma-separated list of metric names.
limit
integer
Maximum number of results to return (between 1 and 5000) - defaults to 500 results if limit not specified.
next_record_id
string
List following results with a next_record_id provided in the previous query.
"""
Get all custom metrics by hourly average returns "OK" response
"""fromdatetimeimportdatetimefromdateutil.relativedeltaimportrelativedeltafromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v1.api.usage_metering_apiimportUsageMeteringApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=UsageMeteringApi(api_client)response=api_instance.get_usage_top_avg_metrics(day=(datetime.now()+relativedelta(days=-3)),)print(response)
# Get all custom metrics by hourly average returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V1::UsageMeteringAPI.newopts={day:(Time.now+-3*86400),}papi_instance.get_usage_top_avg_metrics(opts)
// Get all custom metrics by hourly average returns "OK" responsepackagemainimport("context""encoding/json""fmt""os""time""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV1")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV1.NewUsageMeteringApi(apiClient)resp,r,err:=api.GetUsageTopAvgMetrics(ctx,*datadogV1.NewGetUsageTopAvgMetricsOptionalParameters().WithDay(time.Now().AddDate(0,0,-3)))iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `UsageMeteringApi.GetUsageTopAvgMetrics`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `UsageMeteringApi.GetUsageTopAvgMetrics`:\n%s\n",responseContent)}
// Get all custom metrics by hourly average returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v1.api.UsageMeteringApi;importcom.datadog.api.client.v1.api.UsageMeteringApi.GetUsageTopAvgMetricsOptionalParameters;importcom.datadog.api.client.v1.model.UsageTopAvgMetricsResponse;importjava.time.OffsetDateTime;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();UsageMeteringApiapiInstance=newUsageMeteringApi(defaultClient);try{UsageTopAvgMetricsResponseresult=apiInstance.getUsageTopAvgMetrics(newGetUsageTopAvgMetricsOptionalParameters().day(OffsetDateTime.now().plusDays(-3)));System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling UsageMeteringApi#getUsageTopAvgMetrics");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Get all custom metrics by hourly average returns "OK" response
usechrono::{DateTime,Utc};usedatadog_api_client::datadog;usedatadog_api_client::datadogV1::api_usage_metering::GetUsageTopAvgMetricsOptionalParams;usedatadog_api_client::datadogV1::api_usage_metering::UsageMeteringAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=UsageMeteringAPI::with_config(configuration);letresp=api.get_usage_top_avg_metrics(GetUsageTopAvgMetricsOptionalParams::default().day(DateTime::parse_from_rfc3339("2021-11-08T11:11:11+00:00").expect("Failed to parse datetime").with_timezone(&Utc),),).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Get all custom metrics by hourly average returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.UsageMeteringApi(configuration);constparams: v1.UsageMeteringApiGetUsageTopAvgMetricsRequest={day: newDate(newDate().getTime()+-3*86400*1000),};apiInstance.getUsageTopAvgMetrics(params).then((data: v1.UsageTopAvgMetricsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));