List all Datadog Agents

GET https://api.ap1.datadoghq.com/api/v2/fleet/agentshttps://api.ap2.datadoghq.com/api/v2/fleet/agentshttps://api.datadoghq.eu/api/v2/fleet/agentshttps://api.ddog-gov.com/api/v2/fleet/agentshttps://api.us2.ddog-gov.com/api/v2/fleet/agentshttps://api.uk1.datadoghq.com/api/v2/fleet/agentshttps://api.datadoghq.com/api/v2/fleet/agentshttps://api.us3.datadoghq.com/api/v2/fleet/agentshttps://api.us5.datadoghq.com/api/v2/fleet/agents

Présentation

Retrieve a paginated list of Datadog Agents.

Returns agents with support for pagination, sorting, and filtering. Use page_number and page_size to navigate pages, filter to narrow by field values, and tags to filter by agent tags.

This endpoint requires the hosts_read permission.

Arguments

Chaînes de requête

Nom

Type

Description

page_number

integer

Page number for pagination, starting at 0.

page_size

integer

Number of agents to return per page. Maximum value is 100. Defaults to 10.

filter

string

Filter string to narrow down agent results.

tags

string

Comma-separated list of tag keys to select which tags are included in each agent’s tags attribute. Does not filter which agents are returned.

sort_attribute

string

Agent attribute to sort results by. Must be a supported attribute name; unsupported values return a 400 error.

sort_descending

boolean

Set to true to sort results in descending order. Defaults to ascending.

Réponse

OK

Response containing a paginated list of Datadog Agents.

Expand All

Champ

Type

Description

data [required]

[object]

Array of agents matching the query criteria.

attributes [required]

object

Attributes of a Datadog Agent in the v2 list response.

agent_version

string

The Datadog Agent version.

api_key_name

string

The name of the API key used by the agent, if available and not redacted.

api_key_uuid

string

The UUID of the API key used by the agent.

cloud_provider

string

The cloud provider where the agent is running.

cluster_name

string

The Kubernetes cluster name, if the agent runs in a cluster.

datadog_data_center

string

The Datadog data center the agent reports to.

ecs_fargate_cluster_name

string

The ECS Fargate cluster name, if the agent runs in an ECS Fargate environment.

ecs_fargate_task_arn

string

The ECS Fargate task ARN, if the agent runs in an ECS Fargate environment.

enabled_products

[string]

Datadog products enabled on the agent.

env

[string]

Environments the agent is reporting from.

first_seen_at

int64

Unix timestamp when the agent was first seen.

fleet_policies

[string]

Identifiers of fleet policies applied to the agent.

hostname

string

The hostname of the agent.

instrumentation_error_counts

int64

Number of instrumentation errors on the agent. Absent from the response when the count is zero.

instrumentation_status

enum

The single-step instrumentation status of the Agent. Allowed enum values: success,failure

integrations

[string]

Names of integrations configured on the agent.

ip_addresses

[string]

IP addresses of the agent host.

is_single_step_instrumentation_enabled

boolean

Whether single-step instrumentation is enabled on the agent.

last_restart_at

int64

Unix timestamp of the last agent restart.

os

string

The operating system of the host.

otel_collector_deployment_types

[string]

OpenTelemetry collector deployment types associated with the agent.

otel_collector_distributions

[string]

OpenTelemetry collector distributions associated with the agent.

otel_collector_versions

[string]

All OpenTelemetry collector versions associated with the agent.

otel_resource_attributes

[string]

OpenTelemetry resource attributes reported by the agent.

pod_name

string

The Kubernetes pod name, if the agent runs as a pod.

remote_agent_management

string

The remote agent management status.

remote_config_status

string

The remote configuration connection status of the agent.

services

[string]

Services running on the agent.

tags

[object]

Tags associated with the agent. Returned as an empty array when the agent has no tags.

key

string

The tag key.

value

string

The tag value.

team

string

The team associated with the agent.

id [required]

string

The unique agent key identifier.

type [required]

enum

The type of the agent resource. Allowed enum values: agent

default: agent

meta

object

Metadata for the v2 list of agents, including pagination information.

page

object

Pagination details for the v2 list of agents.

total_count

int64

Total number of agents in the fleet, regardless of any filter.

total_filtered_count

int64

Total number of agents matching the current filter criteria.

{
  "data": [
    {
      "attributes": {
        "agent_version": "7.50.0",
        "api_key_name": "Production API Key",
        "api_key_uuid": "a1b2c3d4-e5f6-4321-a123-123456789abc",
        "cloud_provider": "aws",
        "cluster_name": "production-us-east-1",
        "datadog_data_center": "us1",
        "ecs_fargate_cluster_name": "my-ecs-cluster",
        "ecs_fargate_task_arn": "arn:aws:ecs:us-east-1:123456789012:task/my-cluster/abc123",
        "enabled_products": [],
        "env": [],
        "first_seen_at": 1699900000,
        "fleet_policies": [],
        "hostname": "my-hostname",
        "instrumentation_error_counts": 3,
        "instrumentation_status": "success",
        "integrations": [],
        "ip_addresses": [],
        "is_single_step_instrumentation_enabled": true,
        "last_restart_at": 1699999999,
        "os": "linux",
        "otel_collector_deployment_types": [],
        "otel_collector_distributions": [],
        "otel_collector_versions": [],
        "otel_resource_attributes": [],
        "pod_name": "datadog-agent-abc123",
        "remote_agent_management": "enabled",
        "remote_config_status": "connected",
        "services": [],
        "tags": [
          {
            "key": "string",
            "value": "string"
          }
        ],
        "team": "platform"
      },
      "id": "my-agent-hostname",
      "type": "agent"
    }
  ],
  "meta": {
    "page": {
      "total_count": 500,
      "total_filtered_count": 42
    }
  }
}

Bad Request

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

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

Unauthorized

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

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

Forbidden

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

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

Too many requests

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

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

Exemple de code

                  # Curl command
curl -X GET "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.uk1.datadoghq.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/fleet/agents" \ -H "Accept: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
# List all Datadog Agents returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::FleetAutomationAPI.new
p api_instance.list_fleet_agents_v2()

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.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// List all Datadog Agents returns "OK" response

package main

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

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

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewFleetAutomationApi(apiClient)
	resp, r, err := api.ListFleetAgentsV2(ctx, *datadogV2.NewListFleetAgentsV2OptionalParameters())

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `FleetAutomationApi.ListFleetAgentsV2`:\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.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
/**
 * List all Datadog Agents returns "OK" response
 */

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

const configuration = client.createConfiguration();
const apiInstance = new v2.FleetAutomationApi(configuration);

apiInstance
  .listFleetAgentsV2()
  .then((data: v2.FleetAgentsV2Response) => {
    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.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"