ホスト
Dash が新機能を発表!インシデントマネジメント、Continuous Profiler など多数の機能が追加されました! Dash イベントで発表された新機能!

ホスト

Datadog でライブホストに関する情報を取得します。

組織のすべてのホストを取得する

GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/hosts

概要

このエンドポイントを使用して、名前、エイリアス、タグによりホストを検索できます。 過去 3 時間以内に動作したホストが対象です。 保持期間は 7 日間です。 1 回につき最大 1000 件の検索結果がページ調整され表示されます。

引数

クエリ文字列

名前

種類

説明

filter

string

String to filter search results.

sort_field

string

Sort hosts by this field.

sort_dir

string

Direction of sort. Options include asc and desc.

start

integer

Host result to start search from.

count

integer

Number of hosts to return. Max 1000.

from

integer

Number of seconds since UNIX epoch from which you want to search your hosts.

include_muted_hosts_data

boolean

Include information on the muted status of hosts and when the mute expires.

include_hosts_metadata

boolean

Include additional metadata about the hosts (agent_version, machine, platform, processor, etc.).

応答

OK

Response with Host information from Datadog.

Expand All

フィールド

種類

説明

host_list

[object]

Array of hosts.

aliases

[string]

Host aliases collected by Datadog.

apps

[string]

The Datadog integrations reporting metrics for the host.

aws_name

string

AWS name of your host.

host_name

string

The host name.

id

int64

The host ID.

is_muted

boolean

If a host is muted or unmuted.

last_reported_time

int64

Last time the host reported a metric data point.

meta

object

Metadata associated with your host.

nixV

[string]

Array of Unix versions.

metrics

object

Host Metrics collected.

cpu

double

The percent of CPU used (everything but idle).

iowait

double

The percent of CPU spent waiting on the IO (not reported for all platforms).

load

double

The system load over the last 15 minutes.

mute_timeout

int64

Timeout of the mute applied to your host.

name

string

The host name.

sources

[string]

Source or cloud provider associated with your host.

tags_by_source

object

List of tags for each source (AWS, Datadog Agent, Chef..).

<any-key>

[string]

Array of tags for a single source.

up

boolean

Displays UP when the expected metrics are received and displays ??? if no metrics are received.

total_matching

int64

Number of host matching the query.

total_returned

int64

Number of host returned.

{
  "host_list": [
    {
      "aliases": [
        "mycoolhost-1"
      ],
      "apps": [
        "agent"
      ],
      "aws_name": "mycoolhost-1",
      "host_name": "i-deadbeef",
      "id": 123456,
      "is_muted": false,
      "last_reported_time": 1565000000,
      "meta": {
        "nixV": [
          "Ubuntu"
        ]
      },
      "metrics": {
        "cpu": 99,
        "iowait": 3.2,
        "load": 0.5
      },
      "mute_timeout": "integer",
      "name": "i-hostname",
      "sources": [
        "aws"
      ],
      "tags_by_source": {
        "<any-key>": [
          "test.example.com.host"
        ]
      },
      "up": true
    }
  ],
  "total_matching": 1,
  "total_returned": 1
}

Invalid Parameter Error

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

コード例


                                        # Curl command
curl -X GET "https://api.datadoghq.com"https://api.datadoghq.eu/api/v1/hosts" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    filter := "filter_example" // string | String to filter search results. (optional)
    sortField := "sortField_example" // string | Sort hosts by this field. (optional)
    sortDir := "sortDir_example" // string | Direction of sort. Options include `asc` and `desc`. (optional)
    start := 987 // int64 | Host result to start search from. (optional)
    count := 987 // int64 | Number of hosts to return. Max 1000. (optional)
    from := 987 // int64 | Number of seconds since UNIX epoch from which you want to search your hosts. (optional)
    includeMutedHostsData := true // bool | Include information on the muted status of hosts and when the mute expires. (optional)
    includeHostsMetadata := true // bool | Include additional metadata about the hosts (agent_version, machine, platform, processor, etc.). (optional)

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.HostsApi.ListHosts(context.Background()).Filter(filter).SortField(sortField).SortDir(sortDir).Start(start).Count(count).From(from).IncludeMutedHostsData(includeMutedHostsData).IncludeHostsMetadata(includeHostsMetadata).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `HostsApi.ListHosts``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `ListHosts`: HostListResponse
    fmt.Fprintf(os.Stdout, "Response from `HostsApi.ListHosts`: %v\n", resp)
}
// Import classes:
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.HostsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        HostsApi apiInstance = new HostsApi(defaultClient);
        String filter = "filter_example"; // String | String to filter search results.
        String sortField = "sortField_example"; // String | Sort hosts by this field.
        String sortDir = "sortDir_example"; // String | Direction of sort. Options include `asc` and `desc`.
        Long start = 56L; // Long | Host result to start search from.
        Long count = 56L; // Long | Number of hosts to return. Max 1000.
        Long from = 56L; // Long | Number of seconds since UNIX epoch from which you want to search your hosts.
        Boolean includeMutedHostsData = true; // Boolean | Include information on the muted status of hosts and when the mute expires.
        Boolean includeHostsMetadata = true; // Boolean | Include additional metadata about the hosts (agent_version, machine, platform, processor, etc.).
        try {
            HostListResponse result = api.listHosts()
                .filter(filter)
                .sortField(sortField)
                .sortDir(sortDir)
                .start(start)
                .count(count)
                .from(from)
                .includeMutedHostsData(includeMutedHostsData)
                .includeHostsMetadata(includeHostsMetadata)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling HostsApi#listHosts");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

api.Hosts.search()
require 'rubygems'
require 'dogapi'

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

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

dog.search_hosts()

アクティブなホストの総数を取得する

GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/hosts/totals

概要

このエンドポイントは、Datadog アカウントでアクティブなホストと作動中のホストの総数を返します。 アクティブなホストとは、過去 1 時間以内に報告を行ったホストで、作動中のホストとは、過去 2 時間以内に報告を行ったホストです。

引数

クエリ文字列

名前

種類

説明

from

integer

Number of seconds from which you want to get total number of active hosts.

応答

OK

Total number of host currently monitored by Datadog.

Expand All

フィールド

種類

説明

total_active

int64

Total number of active host (UP and ???) reporting to Datadog.

total_up

int64

Number of host that are UP and reporting to Datadog.

{
  "total_active": "integer",
  "total_up": "integer"
}

Invalid Parameter Error

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

コード例


                                        # Curl command
curl -X GET "https://api.datadoghq.com"https://api.datadoghq.eu/api/v1/hosts/totals" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    from := 987 // int64 | Number of seconds from which you want to get total number of active hosts. (optional)

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.HostsApi.GetHostTotals(context.Background()).From(from).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `HostsApi.GetHostTotals``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetHostTotals`: HostTotals
    fmt.Fprintf(os.Stdout, "Response from `HostsApi.GetHostTotals`: %v\n", resp)
}
// Import classes:
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.HostsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        HostsApi apiInstance = new HostsApi(defaultClient);
        Long from = 56L; // Long | Number of seconds from which you want to get total number of active hosts.
        try {
            HostTotals result = api.getHostTotals()
                .from(from)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling HostsApi#getHostTotals");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

api.Hosts.totals()
require 'rubygems'
require 'dogapi'

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

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

dog.host_totals()

ホストのミュート

POST https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/host/{host_name}/mute

概要

ホストをミュートします。

引数

パスパラメーター

名前

種類

説明

host_name [required]

string

Name of the host to mute.

リクエスト

Body Data

ホストのリクエスト本文をミュートします。

Expand All

フィールド

種類

説明

end

int64

POSIX timestamp in seconds when the host is unmuted. If omitted, the host remains muted until explicitly unmuted.

message

string

Message to associate with the muting of this host.

override

boolean

If true and the host is already muted, replaces existing host mute settings.

{
  "end": 1579098130,
  "message": "Muting this host for a test!",
  "override": false
}

応答

OK

Response with the list of muted host for your organization.

Expand All

フィールド

種類

説明

action

string

Action applied to the hosts.

end

int64

POSIX timestamp in seconds when the host is unmuted.

hostname

string

The host name.

message

string

Message associated with the mute.

{
  "action": "Muted",
  "end": 1579098130,
  "hostname": "test.host",
  "message": "Muting this host for a test!"
}

Invalid Parameter Error

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

コード例


                                        # Path parameters
export host_name="CHANGE_ME"
# Curl command curl -X POST "https://api.datadoghq.com"https://api.datadoghq.eu/api/v1/host/${host_name}/mute" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \ -d @- << EOF {} EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    hostName := "hostName_example" // string | Name of the host to mute.
    body := *datadog.NewHostMuteSettings() // HostMuteSettings | Mute a host request body. (optional)

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.HostsApi.MuteHost(context.Background(), hostName).Body(body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `HostsApi.MuteHost``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `MuteHost`: HostMuteResponse
    fmt.Fprintf(os.Stdout, "Response from `HostsApi.MuteHost`: %v\n", resp)
}
// Import classes:
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.HostsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        HostsApi apiInstance = new HostsApi(defaultClient);
        String hostName = "hostName_example"; // String | Name of the host to mute.
        HostMuteSettings body = new HostMuteSettings(); // HostMuteSettings | Mute a host request body.
        try {
            HostMuteResponse result = api.muteHost(hostName)
                .body(body)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling HostsApi#muteHost");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

ホストのミュートを解除

POST https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/host/{host_name}/unmute

概要

ホストのミュートを解除します。このエンドポイントは JSON 引数を受け取りません。

引数

パスパラメーター

名前

種類

説明

host_name [required]

string

Name of the host to unmute.

応答

OK

Response with the list of muted host for your organization.

Expand All

フィールド

種類

説明

action

string

Action applied to the hosts.

end

int64

POSIX timestamp in seconds when the host is unmuted.

hostname

string

The host name.

message

string

Message associated with the mute.

{
  "action": "Muted",
  "end": 1579098130,
  "hostname": "test.host",
  "message": "Muting this host for a test!"
}

Invalid Parameter Error

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

コード例


                                        # Path parameters
export host_name="CHANGE_ME"
# Curl command curl -X POST "https://api.datadoghq.com"https://api.datadoghq.eu/api/v1/host/${host_name}/unmute" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    hostName := "hostName_example" // string | Name of the host to unmute.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.HostsApi.UnmuteHost(context.Background(), hostName).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `HostsApi.UnmuteHost``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `UnmuteHost`: HostMuteResponse
    fmt.Fprintf(os.Stdout, "Response from `HostsApi.UnmuteHost`: %v\n", resp)
}
// Import classes:
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.HostsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        HostsApi apiInstance = new HostsApi(defaultClient);
        String hostName = "hostName_example"; // String | Name of the host to unmute.
        try {
            HostMuteResponse result = api.unmuteHost(hostName)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling HostsApi#unmuteHost");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}