Mesure de l'utilisation

L’API de mesure de l’utilisation vous permet de récupérer des informations sur l’utilisation horaire, journalière et mensuelle de nombreuses facettes de Datadog. Tous les clients Pro et Enterprise peuvent utiliser cette API. Seules les [organisations de niveau parent] peuvent l’utiliser (https://docs.datadoghq.com/account_management/multi_organization/).

Remarque : les données d’utilisation peuvent accuser d’un retard de 72 heures après leur collecte. Elles sont conservées pendant 15 mois.

GET https://api.datadoghq.eu/api/v1/usage/logs-by-retentionhttps://api.ddog-gov.com/api/v1/usage/logs-by-retentionhttps://api.datadoghq.com/api/v1/usage/logs-by-retentionhttps://api.us3.datadoghq.com/api/v1/usage/logs-by-retentionhttps://api.us5.datadoghq.com/api/v1/usage/logs-by-retention

Présentation

Récupérez l’utilisation horaire pour les logs indexés selon la période de rétention. This endpoint requires the usage_read authorization scope.

Arguments

Chaînes de requête

Nom

Type

Description

start_hr [required]

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

end_hr

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

Réponse

OK

Response containing the indexed logs usage broken down by retention period for an organization during a given hour.

Expand All

Champ

Type

Description

usage

[object]

Get hourly usage for indexed logs by retention period.

indexed_events_count

int64

Total logs indexed with this retention period during a given hour.

live_indexed_events_count

int64

Live logs indexed with this retention period during a given hour.

org_name

string

The organization name.

public_id

string

The organization public ID.

rehydrated_indexed_events_count

int64

Rehydrated logs indexed with this retention period during a given hour.

retention

string

The retention period in days or "custom" for all custom retention usage.

{
  "usage": [
    {
      "indexed_events_count": "integer",
      "live_indexed_events_count": "integer",
      "org_name": "string",
      "public_id": "string",
      "rehydrated_indexed_events_count": "integer",
      "retention": "string"
    }
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden - User is not authorized

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Required query arguments
export start_hr="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/usage/logs-by-retention?start_hr=${start_hr}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get hourly logs usage by retention returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = UsageMeteringApi(api_client)
    response = api_instance.get_usage_logs_by_retention(
        start_hr=(datetime.now() + relativedelta(days=-5)).isoformat(timespec="seconds"),
        end_hr=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get hourly logs usage by retention returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::UsageMeteringAPI.new
opts = {
  end_hr: (Time.now + -3 * 86400),
}
p api_instance.get_usage_logs_by_retention((Time.now + -5 * 86400), opts)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get hourly logs usage by retention returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.UsageMeteringApi(configuration);

const params: v1.UsageMeteringApiGetUsageLogsByRetentionRequest = {
  startHr: new Date(new Date().getTime() / 1000 + -5 * 86400),
  endHr: new Date(new Date().getTime() / 1000 + -3 * 86400),
};

apiInstance
  .getUsageLogsByRetention(params)
  .then((data: v1.UsageLogsByRetentionResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get hourly logs usage by retention returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.UsageMeteringApi.GetUsageLogsByRetention(ctx, time.Now().AddDate(0, 0, -5), *datadog.NewGetUsageLogsByRetentionOptionalParameters().WithEndHr(time.Now().AddDate(0, 0, -3)))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetUsageLogsByRetention`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.GetUsageLogsByRetention`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get hourly logs usage by retention returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.UsageMeteringApi;
import com.datadog.api.v1.client.api.UsageMeteringApi.GetUsageLogsByRetentionOptionalParameters;
import com.datadog.api.v1.client.model.UsageLogsByRetentionResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

    try {
      UsageLogsByRetentionResponse result =
          apiInstance.getUsageLogsByRetention(
              OffsetDateTime.now().plusDays(-5),
              new GetUsageLogsByRetentionOptionalParameters()
                  .endHr(OffsetDateTime.now().plusDays(-3)));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsageMeteringApi#getUsageLogsByRetention");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/usage/hostshttps://api.ddog-gov.com/api/v1/usage/hostshttps://api.datadoghq.com/api/v1/usage/hostshttps://api.us3.datadoghq.com/api/v1/usage/hostshttps://api.us5.datadoghq.com/api/v1/usage/hosts

Présentation

Récupérez l’utilisation horaire pour les hosts et les conteneurs. This endpoint requires the usage_read authorization scope.

Arguments

Chaînes de requête

Nom

Type

Description

start_hr [required]

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

end_hr

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

Réponse

OK

Host usage response.

Expand All

Champ

Type

Description

usage

[object]

An array of objects related to host usage.

agent_host_count

int64

Contains the total number of infrastructure hosts reporting during a given hour that were running the Datadog Agent.

alibaba_host_count

int64

Contains the total number of hosts that reported through Alibaba integration (and were NOT running the Datadog Agent).

apm_azure_app_service_host_count

int64

Contains the total number of Azure App Services hosts using APM.

apm_host_count

int64

Shows the total number of hosts using APM during the hour, these are counted as billable (except during trial periods).

aws_host_count

int64

Contains the total number of hosts that reported through the AWS integration (and were NOT running the Datadog Agent).

azure_host_count

int64

Contains the total number of hosts that reported through Azure integration (and were NOT running the Datadog Agent).

container_count

int64

Shows the total number of containers reported by the Docker integration during the hour.

gcp_host_count

int64

Contains the total number of hosts that reported through the Google Cloud integration (and were NOT running the Datadog Agent).

heroku_host_count

int64

Contains the total number of Heroku dynos reported by the Datadog Agent.

host_count

int64

Contains the total number of billable infrastructure hosts reporting during a given hour. This is the sum of agent_host_count, aws_host_count, and gcp_host_count.

hour

date-time

The hour for the usage.

infra_azure_app_service

int64

Contains the total number of hosts that reported through the Azure App Services integration (and were NOT running the Datadog Agent).

opentelemetry_host_count

int64

Contains the total number of hosts reported by Datadog exporter for the OpenTelemetry Collector.

org_name

string

The organization name.

public_id

string

The organization public ID.

vsphere_host_count

int64

Contains the total number of hosts that reported through vSphere integration (and were NOT running the Datadog Agent).

{
  "usage": [
    {
      "agent_host_count": "integer",
      "alibaba_host_count": "integer",
      "apm_azure_app_service_host_count": "integer",
      "apm_host_count": "integer",
      "aws_host_count": "integer",
      "azure_host_count": "integer",
      "container_count": "integer",
      "gcp_host_count": "integer",
      "heroku_host_count": "integer",
      "host_count": "integer",
      "hour": "2019-09-19T10:00:00.000Z",
      "infra_azure_app_service": "integer",
      "opentelemetry_host_count": "integer",
      "org_name": "string",
      "public_id": "string",
      "vsphere_host_count": "integer"
    }
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden - User is not authorized

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Required query arguments
export start_hr="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/usage/hosts?start_hr=${start_hr}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get hourly usage for hosts and containers returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = UsageMeteringApi(api_client)
    response = api_instance.get_usage_hosts(
        start_hr=(datetime.now() + relativedelta(days=-5)).isoformat(timespec="seconds"),
        end_hr=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get hourly usage for hosts and containers returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::UsageMeteringAPI.new
opts = {
  end_hr: (Time.now + -3 * 86400),
}
p api_instance.get_usage_hosts((Time.now + -5 * 86400), opts)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

start_date= '2019-10-07T00'
end_date='2019-10-07T02'

dog.get_hosts_usage(start_date, end_date)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get hourly usage for hosts and containers returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.UsageMeteringApi(configuration);

const params: v1.UsageMeteringApiGetUsageHostsRequest = {
  startHr: new Date(new Date().getTime() / 1000 + -5 * 86400),
  endHr: new Date(new Date().getTime() / 1000 + -3 * 86400),
};

apiInstance
  .getUsageHosts(params)
  .then((data: v1.UsageHostsResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get hourly usage for hosts and containers returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.UsageMeteringApi.GetUsageHosts(ctx, time.Now().AddDate(0, 0, -5), *datadog.NewGetUsageHostsOptionalParameters().WithEndHr(time.Now().AddDate(0, 0, -3)))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetUsageHosts`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.GetUsageHosts`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get hourly usage for hosts and containers returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.UsageMeteringApi;
import com.datadog.api.v1.client.api.UsageMeteringApi.GetUsageHostsOptionalParameters;
import com.datadog.api.v1.client.model.UsageHostsResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

    try {
      UsageHostsResponse result =
          apiInstance.getUsageHosts(
              OffsetDateTime.now().plusDays(-5),
              new GetUsageHostsOptionalParameters().endHr(OffsetDateTime.now().plusDays(-3)));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsageMeteringApi#getUsageHosts");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/usage/logshttps://api.ddog-gov.com/api/v1/usage/logshttps://api.datadoghq.com/api/v1/usage/logshttps://api.us3.datadoghq.com/api/v1/usage/logshttps://api.us5.datadoghq.com/api/v1/usage/logs

Présentation

Récupérez l’utilisation horaire pour les logs. This endpoint requires the usage_read authorization scope.

Arguments

Chaînes de requête

Nom

Type

Description

start_hr [required]

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

end_hr

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

Réponse

OK

Response containing the number of logs for each hour.

Expand All

Champ

Type

Description

usage

[object]

An array of objects regarding hourly usage of logs.

billable_ingested_bytes

int64

Contains the number of billable log bytes ingested.

hour

date-time

The hour for the usage.

indexed_events_count

int64

Contains the number of log events indexed.

ingested_events_bytes

int64

Contains the number of log bytes ingested.

logs_live_indexed_count

int64

Contains the number of live log events indexed (data available as of December 1, 2020).

logs_live_ingested_bytes

int64

Contains the number of live log bytes ingested (data available as of December 1, 2020).

logs_rehydrated_indexed_count

int64

Contains the number of rehydrated log events indexed (data available as of December 1, 2020).

logs_rehydrated_ingested_bytes

int64

Contains the number of rehydrated log bytes ingested (data available as of December 1, 2020).

org_name

string

The organization name.

public_id

string

The organization public ID.

{
  "usage": [
    {
      "billable_ingested_bytes": "integer",
      "hour": "2019-09-19T10:00:00.000Z",
      "indexed_events_count": "integer",
      "ingested_events_bytes": "integer",
      "logs_live_indexed_count": "integer",
      "logs_live_ingested_bytes": "integer",
      "logs_rehydrated_indexed_count": "integer",
      "logs_rehydrated_ingested_bytes": "integer",
      "org_name": "string",
      "public_id": "string"
    }
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden - User is not authorized

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Required query arguments
export start_hr="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/usage/logs?start_hr=${start_hr}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get hourly usage for Logs returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = UsageMeteringApi(api_client)
    response = api_instance.get_usage_logs(
        start_hr=(datetime.now() + relativedelta(days=-5)).isoformat(timespec="seconds"),
        end_hr=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get hourly usage for Logs returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::UsageMeteringAPI.new
opts = {
  end_hr: (Time.now + -3 * 86400),
}
p api_instance.get_usage_logs((Time.now + -5 * 86400), opts)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

start_date= '2019-10-07T00'
end_date='2019-10-07T02'

dog.get_logs_usage(start_date, end_date)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get hourly usage for Logs returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.UsageMeteringApi(configuration);

const params: v1.UsageMeteringApiGetUsageLogsRequest = {
  startHr: new Date(new Date().getTime() / 1000 + -5 * 86400),
  endHr: new Date(new Date().getTime() / 1000 + -3 * 86400),
};

apiInstance
  .getUsageLogs(params)
  .then((data: v1.UsageLogsResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get hourly usage for Logs returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.UsageMeteringApi.GetUsageLogs(ctx, time.Now().AddDate(0, 0, -5), *datadog.NewGetUsageLogsOptionalParameters().WithEndHr(time.Now().AddDate(0, 0, -3)))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetUsageLogs`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.GetUsageLogs`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get hourly usage for Logs returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.UsageMeteringApi;
import com.datadog.api.v1.client.api.UsageMeteringApi.GetUsageLogsOptionalParameters;
import com.datadog.api.v1.client.model.UsageLogsResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

    try {
      UsageLogsResponse result =
          apiInstance.getUsageLogs(
              OffsetDateTime.now().plusDays(-5),
              new GetUsageLogsOptionalParameters().endHr(OffsetDateTime.now().plusDays(-3)));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsageMeteringApi#getUsageLogs");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/usage/logs_by_indexhttps://api.ddog-gov.com/api/v1/usage/logs_by_indexhttps://api.datadoghq.com/api/v1/usage/logs_by_indexhttps://api.us3.datadoghq.com/api/v1/usage/logs_by_indexhttps://api.us5.datadoghq.com/api/v1/usage/logs_by_index

Présentation

Récupérez l’utilisation horaire pour les logs par index. This endpoint requires the usage_read authorization scope.

Arguments

Chaînes de requête

Nom

Type

Description

start_hr [required]

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

end_hr

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

index_name

array

Comma-separated list of log index names.

Réponse

OK

Response containing the number of indexed logs for each hour and index for a given organization.

Expand All

Champ

Type

Description

usage

[object]

An array of objects regarding hourly usage of logs by index response.

event_count

int64

The total number of indexed logs for the queried hour.

hour

date-time

The hour for the usage.

index_id

string

The index ID for this usage.

index_name

string

The user specified name for this index ID.

org_name

string

The organization name.

public_id

string

The organization public ID.

retention

int64

The retention period (in days) for this index ID.

{
  "usage": [
    {
      "event_count": "integer",
      "hour": "2019-09-19T10:00:00.000Z",
      "index_id": "string",
      "index_name": "string",
      "org_name": "string",
      "public_id": "string",
      "retention": "integer"
    }
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden - User is not authorized

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Required query arguments
export start_hr="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/usage/logs_by_index?start_hr=${start_hr}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get hourly usage for Logs by Index returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = UsageMeteringApi(api_client)
    response = api_instance.get_usage_logs_by_index(
        start_hr=(datetime.now() + relativedelta(days=-5)).isoformat(timespec="seconds"),
        end_hr=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get hourly usage for Logs by Index returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::UsageMeteringAPI.new
opts = {
  end_hr: (Time.now + -3 * 86400),
}
p api_instance.get_usage_logs_by_index((Time.now + -5 * 86400), opts)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

start_date= '2020-01-01T00'
end_date='2019-01-01T02'
index_name='main, marketing'

dog.get_logs_by_index_usage(start_date, end_date, index_name)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get hourly usage for Logs by Index returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.UsageMeteringApi(configuration);

const params: v1.UsageMeteringApiGetUsageLogsByIndexRequest = {
  startHr: new Date(new Date().getTime() / 1000 + -5 * 86400),
  endHr: new Date(new Date().getTime() / 1000 + -3 * 86400),
};

apiInstance
  .getUsageLogsByIndex(params)
  .then((data: v1.UsageLogsByIndexResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get hourly usage for Logs by Index returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.UsageMeteringApi.GetUsageLogsByIndex(ctx, time.Now().AddDate(0, 0, -5), *datadog.NewGetUsageLogsByIndexOptionalParameters().WithEndHr(time.Now().AddDate(0, 0, -3)))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetUsageLogsByIndex`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.GetUsageLogsByIndex`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get hourly usage for Logs by Index returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.UsageMeteringApi;
import com.datadog.api.v1.client.api.UsageMeteringApi.GetUsageLogsByIndexOptionalParameters;
import com.datadog.api.v1.client.model.UsageLogsByIndexResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

    try {
      UsageLogsByIndexResponse result =
          apiInstance.getUsageLogsByIndex(
              OffsetDateTime.now().plusDays(-5),
              new GetUsageLogsByIndexOptionalParameters().endHr(OffsetDateTime.now().plusDays(-3)));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsageMeteringApi#getUsageLogsByIndex");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
# Consult the ruby example

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"

GET https://api.datadoghq.eu/api/v1/usage/timeserieshttps://api.ddog-gov.com/api/v1/usage/timeserieshttps://api.datadoghq.com/api/v1/usage/timeserieshttps://api.us3.datadoghq.com/api/v1/usage/timeserieshttps://api.us5.datadoghq.com/api/v1/usage/timeseries

Présentation

Récupérez l’utilisation horaire pour les [métriques custom] (https://docs.datadoghq.com/developers/metrics/custom_metrics/). This endpoint requires the usage_read authorization scope.

Arguments

Chaînes de requête

Nom

Type

Description

start_hr [required]

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

end_hr

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

Réponse

OK

Response containing hourly usage of timeseries.

Expand All

Champ

Type

Description

usage

[object]

An array of objects regarding hourly usage of timeseries.

hour

date-time

The hour for the usage.

num_custom_input_timeseries

int64

Contains the number of custom metrics that are inputs for aggregations (metric configured is custom).

num_custom_output_timeseries

int64

Contains the number of custom metrics that are outputs for aggregations (metric configured is custom).

num_custom_timeseries

int64

Contains sum of non-aggregation custom metrics and custom metrics that are outputs for aggregations.

org_name

string

The organization name.

public_id

string

The organization public ID.

{
  "usage": [
    {
      "hour": "2019-09-19T10:00:00.000Z",
      "num_custom_input_timeseries": "integer",
      "num_custom_output_timeseries": "integer",
      "num_custom_timeseries": "integer",
      "org_name": "string",
      "public_id": "string"
    }
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden - User is not authorized

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Required query arguments
export start_hr="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/usage/timeseries?start_hr=${start_hr}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get hourly usage for custom metrics returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = UsageMeteringApi(api_client)
    response = api_instance.get_usage_timeseries(
        start_hr=(datetime.now() + relativedelta(days=-5)).isoformat(timespec="seconds"),
        end_hr=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get hourly usage for custom metrics returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::UsageMeteringAPI.new
opts = {
  end_hr: (Time.now + -3 * 86400),
}
p api_instance.get_usage_timeseries((Time.now + -5 * 86400), opts)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

start_date= '2019-10-07T00'
end_date='2019-10-07T02'

dog.get_custom_metrics_usage(start_date, end_date)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get hourly usage for custom metrics returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.UsageMeteringApi(configuration);

const params: v1.UsageMeteringApiGetUsageTimeseriesRequest = {
  startHr: new Date(new Date().getTime() / 1000 + -5 * 86400),
  endHr: new Date(new Date().getTime() / 1000 + -3 * 86400),
};

apiInstance
  .getUsageTimeseries(params)
  .then((data: v1.UsageTimeseriesResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get hourly usage for custom metrics returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.UsageMeteringApi.GetUsageTimeseries(ctx, time.Now().AddDate(0, 0, -5), *datadog.NewGetUsageTimeseriesOptionalParameters().WithEndHr(time.Now().AddDate(0, 0, -3)))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetUsageTimeseries`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.GetUsageTimeseries`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get hourly usage for custom metrics returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.UsageMeteringApi;
import com.datadog.api.v1.client.api.UsageMeteringApi.GetUsageTimeseriesOptionalParameters;
import com.datadog.api.v1.client.model.UsageTimeseriesResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

    try {
      UsageTimeseriesResponse result =
          apiInstance.getUsageTimeseries(
              OffsetDateTime.now().plusDays(-5),
              new GetUsageTimeseriesOptionalParameters().endHr(OffsetDateTime.now().plusDays(-3)));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsageMeteringApi#getUsageTimeseries");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/usage/top_avg_metricshttps://api.ddog-gov.com/api/v1/usage/top_avg_metricshttps://api.datadoghq.com/api/v1/usage/top_avg_metricshttps://api.us3.datadoghq.com/api/v1/usage/top_avg_metricshttps://api.us5.datadoghq.com/api/v1/usage/top_avg_metrics

Présentation

Récupérez toutes les métriques custom selon la moyenne horaire. Le paramètre « month » vous permet d’obtenir une résolution des données du mois actuel, tandis que le paramètre « day » vous permet d’obtenir une résolution quotidienne. Vous devez impérativement définir l’un de ces deux paramètres (mais pas les deux). This endpoint requires the usage_read authorization scope.

Arguments

Chaînes de requête

Nom

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.

Réponse

OK

Response containing the number of hourly recorded custom metrics for a given organization.

Expand All

Champ

Type

Description

metadata

object

The object containing document metadata.

day

date-time

The day value from the user request that contains the returned usage data. (If day was used the request)

month

date-time

The month value from the user request that contains the returned usage data. (If month was used the request)

pagination

object

The metadata for the current pagination.

limit

int64

Maximum amount of records to be returned.

next_record_id

string

The cursor to get the next results (if any). To make the next request, use the same parameters and add next_record_id.

total_number_of_records

int64

Total number of records.

usage

[object]

Number of hourly recorded custom metrics for a given organization.

avg_metric_hour

int64

Average number of timeseries per hour in which the metric occurs.

max_metric_hour

int64

Maximum number of timeseries per hour in which the metric occurs.

metric_category

enum

Contains the metric category. Allowed enum values: standard,custom

metric_name

string

Contains the custom metric name.

{
  "metadata": {
    "day": "2019-09-19T10:00:00.000Z",
    "month": "2019-09-19T10:00:00.000Z",
    "pagination": {
      "limit": "integer",
      "next_record_id": "string",
      "total_number_of_records": "integer"
    }
  },
  "usage": [
    {
      "avg_metric_hour": "integer",
      "max_metric_hour": "integer",
      "metric_category": "string",
      "metric_name": "string"
    }
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden - User is not authorized

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Curl command
curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/usage/top_avg_metrics" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get all custom metrics by hourly average returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = UsageMeteringApi(api_client)
    response = api_instance.get_usage_top_avg_metrics(
        day=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get all custom metrics by hourly average returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::UsageMeteringAPI.new
opts = {
  day: (Time.now + -3 * 86400),
}
p api_instance.get_usage_top_avg_metrics(opts)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get all custom metrics by hourly average returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.UsageMeteringApi(configuration);

const params: v1.UsageMeteringApiGetUsageTopAvgMetricsRequest = {
  day: new Date(new Date().getTime() / 1000 + -3 * 86400),
};

apiInstance
  .getUsageTopAvgMetrics(params)
  .then((data: v1.UsageTopAvgMetricsResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get all custom metrics by hourly average returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.UsageMeteringApi.GetUsageTopAvgMetrics(ctx, *datadog.NewGetUsageTopAvgMetricsOptionalParameters().WithDay(time.Now().AddDate(0, 0, -3)))

	if err != 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)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get all custom metrics by hourly average returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.UsageMeteringApi;
import com.datadog.api.v1.client.api.UsageMeteringApi.GetUsageTopAvgMetricsOptionalParameters;
import com.datadog.api.v1.client.model.UsageTopAvgMetricsResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

    try {
      UsageTopAvgMetricsResponse result =
          apiInstance.getUsageTopAvgMetrics(
              new GetUsageTopAvgMetricsOptionalParameters().day(OffsetDateTime.now().plusDays(-3)));
      System.out.println(result);
    } catch (ApiException e) {
      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();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/usage/indexed-spanshttps://api.ddog-gov.com/api/v1/usage/indexed-spanshttps://api.datadoghq.com/api/v1/usage/indexed-spanshttps://api.us3.datadoghq.com/api/v1/usage/indexed-spanshttps://api.us5.datadoghq.com/api/v1/usage/indexed-spans

Présentation

Récupérez l’utilisation horaire pour les spans indexées. This endpoint requires the usage_read authorization scope.

Arguments

Chaînes de requête

Nom

Type

Description

start_hr [required]

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

end_hr

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

Réponse

OK

A response containing indexed spans usage.

Expand All

Champ

Type

Description

usage

[object]

Array with the number of hourly traces indexed for a given organization.

hour

date-time

The hour for the usage.

indexed_events_count

int64

Contains the number of spans indexed.

org_name

string

The organization name.

public_id

string

The organization public ID.

{
  "usage": [
    {
      "hour": "2019-09-19T10:00:00.000Z",
      "indexed_events_count": "integer",
      "org_name": "string",
      "public_id": "string"
    }
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden - User is not authorized

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Required query arguments
export start_hr="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/usage/indexed-spans?start_hr=${start_hr}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get hourly usage for indexed spans returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = UsageMeteringApi(api_client)
    response = api_instance.get_usage_indexed_spans(
        start_hr=(datetime.now() + relativedelta(days=-5)).isoformat(timespec="seconds"),
        end_hr=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get hourly usage for indexed spans returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::UsageMeteringAPI.new
opts = {
  end_hr: (Time.now + -3 * 86400),
}
p api_instance.get_usage_indexed_spans((Time.now + -5 * 86400), opts)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get hourly usage for indexed spans returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.UsageMeteringApi(configuration);

const params: v1.UsageMeteringApiGetUsageIndexedSpansRequest = {
  startHr: new Date(new Date().getTime() / 1000 + -5 * 86400),
  endHr: new Date(new Date().getTime() / 1000 + -3 * 86400),
};

apiInstance
  .getUsageIndexedSpans(params)
  .then((data: v1.UsageIndexedSpansResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get hourly usage for indexed spans returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.UsageMeteringApi.GetUsageIndexedSpans(ctx, time.Now().AddDate(0, 0, -5), *datadog.NewGetUsageIndexedSpansOptionalParameters().WithEndHr(time.Now().AddDate(0, 0, -3)))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetUsageIndexedSpans`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.GetUsageIndexedSpans`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get hourly usage for indexed spans returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.UsageMeteringApi;
import com.datadog.api.v1.client.api.UsageMeteringApi.GetUsageIndexedSpansOptionalParameters;
import com.datadog.api.v1.client.model.UsageIndexedSpansResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

    try {
      UsageIndexedSpansResponse result =
          apiInstance.getUsageIndexedSpans(
              OffsetDateTime.now().plusDays(-5),
              new GetUsageIndexedSpansOptionalParameters()
                  .endHr(OffsetDateTime.now().plusDays(-3)));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsageMeteringApi#getUsageIndexedSpans");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/usage/syntheticshttps://api.ddog-gov.com/api/v1/usage/syntheticshttps://api.datadoghq.com/api/v1/usage/syntheticshttps://api.us3.datadoghq.com/api/v1/usage/syntheticshttps://api.us5.datadoghq.com/api/v1/usage/synthetics

Présentation

Récupérez l’utilisation horaire pour les checks Synthetic. This endpoint requires the usage_read authorization scope.

Arguments

Chaînes de requête

Nom

Type

Description

start_hr [required]

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

end_hr

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

Réponse

OK

Response containing the number of Synthetics API tests run for each hour for a given organization.

Expand All

Champ

Type

Description

usage

[object]

Array with the number of hourly Synthetics test run for a given organization.

check_calls_count

int64

Contains the number of Synthetics API tests run.

hour

date-time

The hour for the usage.

org_name

string

The organization name.

public_id

string

The organization public ID.

{
  "usage": [
    {
      "check_calls_count": "integer",
      "hour": "2019-09-19T10:00:00.000Z",
      "org_name": "string",
      "public_id": "string"
    }
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden - User is not authorized

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Required query arguments
export start_hr="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/usage/synthetics?start_hr=${start_hr}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get hourly usage for Synthetics Checks returns "OK" response
"""

from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi
from datetime import datetime
from dateutil.tz import tzutc

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = UsageMeteringApi(api_client)
    response = api_instance.get_usage_synthetics(
        start_hr=datetime(2021, 11, 11, 11, 11, 11, 111000, tzinfo=tzutc()),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get hourly usage for Synthetics Checks returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::UsageMeteringAPI.new
p api_instance.get_usage_synthetics("2021-11-11T11:11:11.111+00:00")

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get hourly usage for Synthetics Checks returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.UsageMeteringApi(configuration);

const params: v1.UsageMeteringApiGetUsageSyntheticsRequest = {
  startHr: new Date(2021, 11, 11, 11, 11, 11, 111000),
};

apiInstance
  .getUsageSynthetics(params)
  .then((data: v1.UsageSyntheticsResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get hourly usage for Synthetics Checks returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.UsageMeteringApi.GetUsageSynthetics(ctx, time.Date(2021, 11, 11, 11, 11, 11, 111000, time.UTC), *datadog.NewGetUsageSyntheticsOptionalParameters())

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetUsageSynthetics`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.GetUsageSynthetics`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get hourly usage for Synthetics Checks returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.UsageMeteringApi;
import com.datadog.api.v1.client.model.UsageSyntheticsResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

    try {
      UsageSyntheticsResponse result =
          apiInstance.getUsageSynthetics(OffsetDateTime.parse("2021-11-11T11:11:11.111+00:00"));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsageMeteringApi#getUsageSynthetics");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/usage/synthetics_apihttps://api.ddog-gov.com/api/v1/usage/synthetics_apihttps://api.datadoghq.com/api/v1/usage/synthetics_apihttps://api.us3.datadoghq.com/api/v1/usage/synthetics_apihttps://api.us5.datadoghq.com/api/v1/usage/synthetics_api

Présentation

Récupérez l’utilisation horaire pour les checks API Synthetic. This endpoint requires the usage_read authorization scope.

Arguments

Chaînes de requête

Nom

Type

Description

start_hr [required]

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

end_hr

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

Réponse

OK

Response containing the number of Synthetics API tests run for each hour for a given organization.

Expand All

Champ

Type

Description

usage

[object]

Get hourly usage for Synthetics API tests.

check_calls_count

int64

Contains the number of Synthetics API tests run.

hour

date-time

The hour for the usage.

org_name

string

The organization name.

public_id

string

The organization public ID.

{
  "usage": [
    {
      "check_calls_count": "integer",
      "hour": "2019-09-19T10:00:00.000Z",
      "org_name": "string",
      "public_id": "string"
    }
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden - User is not authorized

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Required query arguments
export start_hr="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/usage/synthetics_api?start_hr=${start_hr}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get hourly usage for Synthetics API Checks returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = UsageMeteringApi(api_client)
    response = api_instance.get_usage_synthetics_api(
        start_hr=(datetime.now() + relativedelta(days=-5)).isoformat(timespec="seconds"),
        end_hr=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get hourly usage for Synthetics API Checks returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::UsageMeteringAPI.new
opts = {
  end_hr: (Time.now + -3 * 86400),
}
p api_instance.get_usage_synthetics_api((Time.now + -5 * 86400), opts)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

start_date= '2019-10-07T00'
end_date='2019-10-07T02'

dog.get_synthetics_api_usage(start_date, end_date)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get hourly usage for Synthetics API Checks returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.UsageMeteringApi(configuration);

const params: v1.UsageMeteringApiGetUsageSyntheticsAPIRequest = {
  startHr: new Date(new Date().getTime() / 1000 + -5 * 86400),
  endHr: new Date(new Date().getTime() / 1000 + -3 * 86400),
};

apiInstance
  .getUsageSyntheticsAPI(params)
  .then((data: v1.UsageSyntheticsAPIResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get hourly usage for Synthetics API Checks returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.UsageMeteringApi.GetUsageSyntheticsAPI(ctx, time.Now().AddDate(0, 0, -5), *datadog.NewGetUsageSyntheticsAPIOptionalParameters().WithEndHr(time.Now().AddDate(0, 0, -3)))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetUsageSyntheticsAPI`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.GetUsageSyntheticsAPI`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get hourly usage for Synthetics API Checks returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.UsageMeteringApi;
import com.datadog.api.v1.client.api.UsageMeteringApi.GetUsageSyntheticsAPIOptionalParameters;
import com.datadog.api.v1.client.model.UsageSyntheticsAPIResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

    try {
      UsageSyntheticsAPIResponse result =
          apiInstance.getUsageSyntheticsAPI(
              OffsetDateTime.now().plusDays(-5),
              new GetUsageSyntheticsAPIOptionalParameters()
                  .endHr(OffsetDateTime.now().plusDays(-3)));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsageMeteringApi#getUsageSyntheticsAPI");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/usage/synthetics_browserhttps://api.ddog-gov.com/api/v1/usage/synthetics_browserhttps://api.datadoghq.com/api/v1/usage/synthetics_browserhttps://api.us3.datadoghq.com/api/v1/usage/synthetics_browserhttps://api.us5.datadoghq.com/api/v1/usage/synthetics_browser

Présentation

Récupérez l’utilisation horaire pour les checks Browser Synthetic. This endpoint requires the usage_read authorization scope.

Arguments

Chaînes de requête

Nom

Type

Description

start_hr [required]

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

end_hr

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

Réponse

OK

Response containing the number of Synthetics Browser tests run for each hour for a given organization.

Expand All

Champ

Type

Description

usage

[object]

Get hourly usage for Synthetics Browser tests.

browser_check_calls_count

int64

Contains the number of Synthetics Browser tests run.

hour

date-time

The hour for the usage.

org_name

string

The organization name.

public_id

string

The organization public ID.

{
  "usage": [
    {
      "browser_check_calls_count": "integer",
      "hour": "2019-09-19T10:00:00.000Z",
      "org_name": "string",
      "public_id": "string"
    }
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden - User is not authorized

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Required query arguments
export start_hr="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/usage/synthetics_browser?start_hr=${start_hr}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get hourly usage for Synthetics Browser Checks returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = UsageMeteringApi(api_client)
    response = api_instance.get_usage_synthetics_browser(
        start_hr=(datetime.now() + relativedelta(days=-5)).isoformat(timespec="seconds"),
        end_hr=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get hourly usage for Synthetics Browser Checks returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::UsageMeteringAPI.new
opts = {
  end_hr: (Time.now + -3 * 86400),
}
p api_instance.get_usage_synthetics_browser((Time.now + -5 * 86400), opts)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

start_date= '2019-10-07T00'
end_date='2019-10-07T02'

dog.get_synthetics_browser_usage(start_date, end_date)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get hourly usage for Synthetics Browser Checks returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.UsageMeteringApi(configuration);

const params: v1.UsageMeteringApiGetUsageSyntheticsBrowserRequest = {
  startHr: new Date(new Date().getTime() / 1000 + -5 * 86400),
  endHr: new Date(new Date().getTime() / 1000 + -3 * 86400),
};

apiInstance
  .getUsageSyntheticsBrowser(params)
  .then((data: v1.UsageSyntheticsBrowserResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get hourly usage for Synthetics Browser Checks returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.UsageMeteringApi.GetUsageSyntheticsBrowser(ctx, time.Now().AddDate(0, 0, -5), *datadog.NewGetUsageSyntheticsBrowserOptionalParameters().WithEndHr(time.Now().AddDate(0, 0, -3)))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetUsageSyntheticsBrowser`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.GetUsageSyntheticsBrowser`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get hourly usage for Synthetics Browser Checks returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.UsageMeteringApi;
import com.datadog.api.v1.client.api.UsageMeteringApi.GetUsageSyntheticsBrowserOptionalParameters;
import com.datadog.api.v1.client.model.UsageSyntheticsBrowserResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

    try {
      UsageSyntheticsBrowserResponse result =
          apiInstance.getUsageSyntheticsBrowser(
              OffsetDateTime.now().plusDays(-5),
              new GetUsageSyntheticsBrowserOptionalParameters()
                  .endHr(OffsetDateTime.now().plusDays(-3)));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsageMeteringApi#getUsageSyntheticsBrowser");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/usage/fargatehttps://api.ddog-gov.com/api/v1/usage/fargatehttps://api.datadoghq.com/api/v1/usage/fargatehttps://api.us3.datadoghq.com/api/v1/usage/fargatehttps://api.us5.datadoghq.com/api/v1/usage/fargate

Présentation

Récupérez l’utilisation horaire pour Fargate. This endpoint requires the usage_read authorization scope.

Arguments

Chaînes de requête

Nom

Type

Description

start_hr [required]

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

end_hr

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

Réponse

OK

Response containing the number of Fargate tasks run and hourly usage.

Expand All

Champ

Type

Description

usage

[object]

Array with the number of hourly Fargate tasks recorded for a given organization.

avg_profiled_fargate_tasks

int64

The average profiled task count for Fargate Profiling.

hour

date-time

The hour for the usage.

org_name

string

The organization name.

public_id

string

The organization public ID.

tasks_count

int64

The number of Fargate tasks run.

{
  "usage": [
    {
      "avg_profiled_fargate_tasks": "integer",
      "hour": "2019-09-19T10:00:00.000Z",
      "org_name": "string",
      "public_id": "string",
      "tasks_count": "integer"
    }
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden - User is not authorized

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Required query arguments
export start_hr="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/usage/fargate?start_hr=${start_hr}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get hourly usage for Fargate returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = UsageMeteringApi(api_client)
    response = api_instance.get_usage_fargate(
        start_hr=(datetime.now() + relativedelta(days=-5)).isoformat(timespec="seconds"),
        end_hr=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get hourly usage for Fargate returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::UsageMeteringAPI.new
opts = {
  end_hr: (Time.now + -3 * 86400),
}
p api_instance.get_usage_fargate((Time.now + -5 * 86400), opts)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

start_date= '2019-10-07T00'
end_date='2019-10-07T02'

dog.get_fargate_usage(start_date, end_date)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get hourly usage for Fargate returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.UsageMeteringApi(configuration);

const params: v1.UsageMeteringApiGetUsageFargateRequest = {
  startHr: new Date(new Date().getTime() / 1000 + -5 * 86400),
  endHr: new Date(new Date().getTime() / 1000 + -3 * 86400),
};

apiInstance
  .getUsageFargate(params)
  .then((data: v1.UsageFargateResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get hourly usage for Fargate returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.UsageMeteringApi.GetUsageFargate(ctx, time.Now().AddDate(0, 0, -5), *datadog.NewGetUsageFargateOptionalParameters().WithEndHr(time.Now().AddDate(0, 0, -3)))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetUsageFargate`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.GetUsageFargate`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get hourly usage for Fargate returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.UsageMeteringApi;
import com.datadog.api.v1.client.api.UsageMeteringApi.GetUsageFargateOptionalParameters;
import com.datadog.api.v1.client.model.UsageFargateResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

    try {
      UsageFargateResponse result =
          apiInstance.getUsageFargate(
              OffsetDateTime.now().plusDays(-5),
              new GetUsageFargateOptionalParameters().endHr(OffsetDateTime.now().plusDays(-3)));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsageMeteringApi#getUsageFargate");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/usage/aws_lambdahttps://api.ddog-gov.com/api/v1/usage/aws_lambdahttps://api.datadoghq.com/api/v1/usage/aws_lambdahttps://api.us3.datadoghq.com/api/v1/usage/aws_lambdahttps://api.us5.datadoghq.com/api/v1/usage/aws_lambda

Présentation

Récupérez l’utilisation horaire pour Lambda. This endpoint requires the usage_read authorization scope.

Arguments

Chaînes de requête

Nom

Type

Description

start_hr [required]

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

end_hr

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

Réponse

OK

Response containing the number of lambda functions and sum of the invocations of all lambda functions for each hour for a given organization.

Expand All

Champ

Type

Description

usage

[object]

Get hourly usage for Lambda.

func_count

int64

Contains the number of different functions for each region and AWS account.

hour

date-time

The hour for the usage.

invocations_sum

int64

Contains the sum of invocations of all functions.

org_name

string

The organization name.

public_id

string

The organization public ID.

{
  "usage": [
    {
      "func_count": "integer",
      "hour": "2019-09-19T10:00:00.000Z",
      "invocations_sum": "integer",
      "org_name": "string",
      "public_id": "string"
    }
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden - User is not authorized

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Required query arguments
export start_hr="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/usage/aws_lambda?start_hr=${start_hr}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get hourly usage for Lambda returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = UsageMeteringApi(api_client)
    response = api_instance.get_usage_lambda(
        start_hr=(datetime.now() + relativedelta(days=-5)).isoformat(timespec="seconds"),
        end_hr=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get hourly usage for Lambda returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::UsageMeteringAPI.new
opts = {
  end_hr: (Time.now + -3 * 86400),
}
p api_instance.get_usage_lambda((Time.now + -5 * 86400), opts)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

start_date= '2019-10-07T00'
end_date='2019-10-07T02'

dog.get_aws_lambda_usage(start_date, end_date)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get hourly usage for Lambda returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.UsageMeteringApi(configuration);

const params: v1.UsageMeteringApiGetUsageLambdaRequest = {
  startHr: new Date(new Date().getTime() / 1000 + -5 * 86400),
  endHr: new Date(new Date().getTime() / 1000 + -3 * 86400),
};

apiInstance
  .getUsageLambda(params)
  .then((data: v1.UsageLambdaResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get hourly usage for Lambda returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.UsageMeteringApi.GetUsageLambda(ctx, time.Now().AddDate(0, 0, -5), *datadog.NewGetUsageLambdaOptionalParameters().WithEndHr(time.Now().AddDate(0, 0, -3)))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetUsageLambda`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.GetUsageLambda`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get hourly usage for Lambda returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.UsageMeteringApi;
import com.datadog.api.v1.client.api.UsageMeteringApi.GetUsageLambdaOptionalParameters;
import com.datadog.api.v1.client.model.UsageLambdaResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

    try {
      UsageLambdaResponse result =
          apiInstance.getUsageLambda(
              OffsetDateTime.now().plusDays(-5),
              new GetUsageLambdaOptionalParameters().endHr(OffsetDateTime.now().plusDays(-3)));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsageMeteringApi#getUsageLambda");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/usage/rum_sessionshttps://api.ddog-gov.com/api/v1/usage/rum_sessionshttps://api.datadoghq.com/api/v1/usage/rum_sessionshttps://api.us3.datadoghq.com/api/v1/usage/rum_sessionshttps://api.us5.datadoghq.com/api/v1/usage/rum_sessions

Présentation

Récupérez l’utilisation horaire pour les sessions RUM. This endpoint requires the usage_read authorization scope.

Arguments

Chaînes de requête

Nom

Type

Description

start_hr [required]

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

end_hr

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

type

string

RUM type: [browser, mobile]. Defaults to browser.

Réponse

OK

Response containing the number of RUM Sessions for each hour for a given organization.

Expand All

Champ

Type

Description

usage

[object]

Get hourly usage for RUM Sessions.

hour

date-time

The hour for the usage.

org_name

string

The organization name.

public_id

string

The organization public ID.

replay_session_count

int64

Contains the number of RUM Replay Sessions (data available beginning November 1, 2021).

session_count

int64

Contains the number of browser RUM Lite Sessions.

session_count_android

int64

Contains the number of mobile RUM Sessions on Android (data available beginning December 1, 2020).

session_count_ios

int64

Contains the number of mobile RUM Sessions on iOS (data available beginning December 1, 2020).

session_count_reactnative

int64

Contains the number of mobile RUM Sessions on React Native (data available beginning May 1, 2022).

{
  "usage": [
    {
      "hour": "2019-09-19T10:00:00.000Z",
      "org_name": "string",
      "public_id": "string",
      "replay_session_count": "integer",
      "session_count": "integer",
      "session_count_android": "integer",
      "session_count_ios": "integer",
      "session_count_reactnative": "integer"
    }
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden - User is not authorized

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Required query arguments
export start_hr="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/usage/rum_sessions?start_hr=${start_hr}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get hourly usage for RUM Sessions returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = UsageMeteringApi(api_client)
    response = api_instance.get_usage_rum_sessions(
        start_hr=(datetime.now() + relativedelta(days=-5)).isoformat(timespec="seconds"),
        end_hr=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get hourly usage for RUM Sessions returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::UsageMeteringAPI.new
opts = {
  end_hr: (Time.now + -3 * 86400),
}
p api_instance.get_usage_rum_sessions((Time.now + -5 * 86400), opts)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

start_date= '2019-10-07T00'
end_date='2019-10-07T02'

dog.get_rum_sessions_usage(start_date, end_date)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get hourly usage for RUM Sessions returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.UsageMeteringApi(configuration);

const params: v1.UsageMeteringApiGetUsageRumSessionsRequest = {
  startHr: new Date(new Date().getTime() / 1000 + -5 * 86400),
  endHr: new Date(new Date().getTime() / 1000 + -3 * 86400),
};

apiInstance
  .getUsageRumSessions(params)
  .then((data: v1.UsageRumSessionsResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get hourly usage for RUM Sessions returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.UsageMeteringApi.GetUsageRumSessions(ctx, time.Now().AddDate(0, 0, -5), *datadog.NewGetUsageRumSessionsOptionalParameters().WithEndHr(time.Now().AddDate(0, 0, -3)))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetUsageRumSessions`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.GetUsageRumSessions`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get hourly usage for RUM Sessions returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.UsageMeteringApi;
import com.datadog.api.v1.client.api.UsageMeteringApi.GetUsageRumSessionsOptionalParameters;
import com.datadog.api.v1.client.model.UsageRumSessionsResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

    try {
      UsageRumSessionsResponse result =
          apiInstance.getUsageRumSessions(
              OffsetDateTime.now().plusDays(-5),
              new GetUsageRumSessionsOptionalParameters().endHr(OffsetDateTime.now().plusDays(-3)));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsageMeteringApi#getUsageRumSessions");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/usage/network_hostshttps://api.ddog-gov.com/api/v1/usage/network_hostshttps://api.datadoghq.com/api/v1/usage/network_hostshttps://api.us3.datadoghq.com/api/v1/usage/network_hostshttps://api.us5.datadoghq.com/api/v1/usage/network_hosts

Présentation

Récupérez l’utilisation horaire pour les hosts réseau. This endpoint requires the usage_read authorization scope.

Arguments

Chaînes de requête

Nom

Type

Description

start_hr [required]

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

end_hr

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

Réponse

OK

Response containing the number of active NPM hosts for each hour for a given organization.

Expand All

Champ

Type

Description

usage

[object]

Get hourly usage for NPM hosts.

host_count

int64

Contains the number of active NPM hosts.

hour

date-time

The hour for the usage.

org_name

string

The organization name.

public_id

string

The organization public ID.

{
  "usage": [
    {
      "host_count": "integer",
      "hour": "2019-09-19T10:00:00.000Z",
      "org_name": "string",
      "public_id": "string"
    }
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden - User is not authorized

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Required query arguments
export start_hr="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/usage/network_hosts?start_hr=${start_hr}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get hourly usage for Network Hosts returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = UsageMeteringApi(api_client)
    response = api_instance.get_usage_network_hosts(
        start_hr=(datetime.now() + relativedelta(days=-5)).isoformat(timespec="seconds"),
        end_hr=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get hourly usage for Network Hosts returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::UsageMeteringAPI.new
opts = {
  end_hr: (Time.now + -3 * 86400),
}
p api_instance.get_usage_network_hosts((Time.now + -5 * 86400), opts)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

start_date= '2019-10-07T00'
end_date='2019-10-07T02'

dog.get_network_hosts_usage(start_date, end_date)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get hourly usage for Network Hosts returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.UsageMeteringApi(configuration);

const params: v1.UsageMeteringApiGetUsageNetworkHostsRequest = {
  startHr: new Date(new Date().getTime() / 1000 + -5 * 86400),
  endHr: new Date(new Date().getTime() / 1000 + -3 * 86400),
};

apiInstance
  .getUsageNetworkHosts(params)
  .then((data: v1.UsageNetworkHostsResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get hourly usage for Network Hosts returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.UsageMeteringApi.GetUsageNetworkHosts(ctx, time.Now().AddDate(0, 0, -5), *datadog.NewGetUsageNetworkHostsOptionalParameters().WithEndHr(time.Now().AddDate(0, 0, -3)))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetUsageNetworkHosts`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.GetUsageNetworkHosts`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get hourly usage for Network Hosts returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.UsageMeteringApi;
import com.datadog.api.v1.client.api.UsageMeteringApi.GetUsageNetworkHostsOptionalParameters;
import com.datadog.api.v1.client.model.UsageNetworkHostsResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

    try {
      UsageNetworkHostsResponse result =
          apiInstance.getUsageNetworkHosts(
              OffsetDateTime.now().plusDays(-5),
              new GetUsageNetworkHostsOptionalParameters()
                  .endHr(OffsetDateTime.now().plusDays(-3)));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsageMeteringApi#getUsageNetworkHosts");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/usage/network_flowshttps://api.ddog-gov.com/api/v1/usage/network_flowshttps://api.datadoghq.com/api/v1/usage/network_flowshttps://api.us3.datadoghq.com/api/v1/usage/network_flowshttps://api.us5.datadoghq.com/api/v1/usage/network_flows

Présentation

Récupérez l’utilisation horaire pour les flux réseau. This endpoint requires the usage_read authorization scope.

Arguments

Chaînes de requête

Nom

Type

Description

start_hr [required]

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

end_hr

string

Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

Réponse

OK

Response containing the number of netflow events indexed for each hour for a given organization.

Expand All

Champ

Type

Description

usage

[object]

Get hourly usage for Network Flows.

hour

date-time

The hour for the usage.

indexed_events_count

int64

Contains the number of netflow events indexed.

org_name

string

The organization name.

public_id

string

The organization public ID.

{
  "usage": [
    {
      "hour": "2019-09-19T10:00:00.000Z",
      "indexed_events_count": "integer",
      "org_name": "string",
      "public_id": "string"
    }
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden - User is not authorized

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Required query arguments
export start_hr="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/usage/network_flows?start_hr=${start_hr}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get hourly usage for Network Flows returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = UsageMeteringApi(api_client)
    response = api_instance.get_usage_network_flows(
        start_hr=(datetime.now() + relativedelta(days=-5)).isoformat(timespec="seconds"),
        end_hr=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get hourly usage for Network Flows returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::UsageMeteringAPI.new
opts = {
  end_hr: (Time.now + -3 * 86400),
}
p api_instance.get_usage_network_flows((Time.now + -5 * 86400), opts)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

start_date= '2019-10-07T00'
end_date='2019-10-07T02'

dog.get_network_flows_usage(start_date, end_date)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get hourly usage for Network Flows returns "OK" response
 */

import { v1 } from "@datadog/datadog-api-client";

const configuration = v1.createConfiguration();
const apiInstance = new v1.UsageMeteringApi(configuration);

const params: v1.UsageMeteringApiGetUsageNetworkFlowsRequest = {
  startHr: new Date(new Date().getTime() / 1000 + -5 * 86400),
  endHr: new Date(new Date().getTime() / 1000 + -3 * 86400),
};

apiInstance
  .getUsageNetworkFlows(params)
  .then((data: v1.UsageNetworkFlowsResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get hourly usage for Network Flows returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.UsageMeteringApi.GetUsageNetworkFlows(ctx, time.Now().AddDate(0, 0, -5), *datadog.NewGetUsageNetworkFlowsOptionalParameters().WithEndHr(time.Now().AddDate(0, 0, -3)))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetUsageNetworkFlows`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.GetUsageNetworkFlows`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get hourly usage for Network Flows returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.UsageMeteringApi;
import com.datadog.api.v1.client.api.UsageMeteringApi.GetUsageNetworkFlowsOptionalParameters;
import com.datadog.api.v1.client.model.UsageNetworkFlowsResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

    try {
      UsageNetworkFlowsResponse result =
          apiInstance.getUsageNetworkFlows(
              OffsetDateTime.now().plusDays(-5),
              new GetUsageNetworkFlowsOptionalParameters()
                  .endHr(OffsetDateTime.now().plusDays(-3)));