Hosts
Rapport de recherche Datadog : Bilan sur l'adoption de l'informatique sans serveur Rapport : Bilan sur l'adoption de l'informatique sans serveur

Hosts

Obtenez des informations sur vos hosts en temps réel dans Datadog.

Récupérer tous les hosts de votre organisation

GET https://api.datadoghq.eu/api/v1/hostshttps://api.datadoghq.com/api/v1/hosts

Présentation

Cet endpoint permet de rechercher les hosts selon leur nom, alias ou tag. Les hosts actifs au cours des 3 dernières heures sont inclus par défaut. La période de rétention est de 7 jours. Les résultats sont paginés avec un maximum de 1 000 résultats par recherche.

Arguments

Chaînes de requête

Nom

Type

Description

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.).

Réponse

OK

Response with Host information from Datadog.

Expand All

Champ

Type

Description

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

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

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.datadoghq.com/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 := int64(789) // int64 | Host result to start search from. (optional)
    count := int64(789) // int64 | Number of hosts to return. Max 1000. (optional)
    from := int64(789) // 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(ctx).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 java.util.*;
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 = apiInstance.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()
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import hosts_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = hosts_api.HostsApi(api_client)
    filter = "filter_example" # str | String to filter search results. (optional)
    sort_field = "sort_field_example" # str | Sort hosts by this field. (optional)
    sort_dir = "sort_dir_example" # str | Direction of sort. Options include `asc` and `desc`. (optional)
    start = 1 # int | Host result to start search from. (optional)
    count = 1 # int | Number of hosts to return. Max 1000. (optional)
    _from = 1 # int | Number of seconds since UNIX epoch from which you want to search your hosts. (optional)
    include_muted_hosts_data = True # bool | Include information on the muted status of hosts and when the mute expires. (optional)
    include_hosts_metadata = True # bool | Include additional metadata about the hosts (agent_version, machine, platform, processor, etc.). (optional)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # Get all hosts for your organization
        api_response = api_instance.list_hosts(filter=filter, sort_field=sort_field, sort_dir=sort_dir, start=start, count=count, _from=_from, include_muted_hosts_data=include_muted_hosts_data, include_hosts_metadata=include_hosts_metadata)
        pprint(api_response)
    except datadog_api_client.v1.ApiException as e:
        print("Exception when calling HostsApi->list_hosts: %s\n" % e)
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()
# load the gem
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V1::HostsApi.new
opts = {
  filter: 'filter_example', # String | String to filter search results.
  sort_field: 'sort_field_example', # String | Sort hosts by this field.
  sort_dir: 'sort_dir_example', # String | Direction of sort. Options include `asc` and `desc`.
  start: 56, # Integer | Host result to start search from.
  count: 56, # Integer | Number of hosts to return. Max 1000.
  from: 56, # Integer | Number of seconds since UNIX epoch from which you want to search your hosts.
  include_muted_hosts_data: true, # Boolean | Include information on the muted status of hosts and when the mute expires.
  include_hosts_metadata: true # Boolean | Include additional metadata about the hosts (agent_version, machine, platform, processor, etc.).
}

begin
  #Get all hosts for your organization
  result = api_instance.list_hosts(opts)
  p result
rescue DatadogAPIClient::V1::ApiError => e
  puts "Exception when calling HostsApi->list_hosts: #{e}"
end

Récupérer le nombre total de hosts actifs

GET https://api.datadoghq.eu/api/v1/hosts/totalshttps://api.datadoghq.com/api/v1/hosts/totals

Présentation

Cet endpoint renvoie le nombre total de hosts actifs et disponibles dans votre compte Datadog. Un host est considéré comme actif lorsqu’il a transmis des données au cours de la dernière heure et disponible lorsque sa dernière transmission de données a été effectuée au cours des deux dernières heures.

Arguments

Chaînes de requête

Nom

Type

Description

from

integer

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

Réponse

OK

Total number of host currently monitored by Datadog.

Expand All

Champ

Type

Description

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

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

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.datadoghq.com/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 := int64(789) // 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(ctx).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 java.util.*;
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 = apiInstance.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()
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import hosts_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = hosts_api.HostsApi(api_client)
    _from = 1 # int | Number of seconds from which you want to get total number of active hosts. (optional)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # Get the total number of active hosts
        api_response = api_instance.get_host_totals(_from=_from)
        pprint(api_response)
    except datadog_api_client.v1.ApiException as e:
        print("Exception when calling HostsApi->get_host_totals: %s\n" % e)
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()
# load the gem
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V1::HostsApi.new
opts = {
  from: 56 # Integer | Number of seconds from which you want to get total number of active hosts.
}

begin
  #Get the total number of active hosts
  result = api_instance.get_host_totals(opts)
  p result
rescue DatadogAPIClient::V1::ApiError => e
  puts "Exception when calling HostsApi->get_host_totals: #{e}"
end

Désactiver un host

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

Présentation

Désactivez un host.

Arguments

Paramètres du chemin

Nom

Type

Description

host_name [required]

string

Name of the host to mute.

Requête

Body Data (required)

Corps de requête pour la désactivation d’un host.

Expand All

Champ

Type

Description

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
}

Réponse

OK

Response with the list of muted host for your organization.

Expand All

Champ

Type

Description

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

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Exemple de code


                                        # Path parameters
export host_name="CHANGE_ME"
# Curl command curl -X POST "https://api.datadoghq.eu"https://api.datadoghq.com/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.

    configuration := datadog.NewConfiguration()

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.HostsApi.MuteHost(ctx, 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 java.util.*;
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 = apiInstance.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();
        }
    }
}
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import hosts_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = hosts_api.HostsApi(api_client)
    host_name = "host_name_example" # str | Name of the host to mute.
    body = HostMuteSettings(
        end=1579098130,
        message="Muting this host for a test!",
        override=False,
    ) # HostMuteSettings | Mute a host request body.

    # example passing only required values which don't have defaults set
    try:
        # Mute a host
        api_response = api_instance.mute_host(host_name, body)
        pprint(api_response)
    except datadog_api_client.v1.ApiException as e:
        print("Exception when calling HostsApi->mute_host: %s\n" % e)
# load the gem
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V1::HostsApi.new
host_name = 'host_name_example' # String | Name of the host to mute.
body = DatadogAPIClient::V1::HostMuteSettings.new # HostMuteSettings | Mute a host request body.

begin
  #Mute a host
  result = api_instance.mute_host(host_name, body)
  p result
rescue DatadogAPIClient::V1::ApiError => e
  puts "Exception when calling HostsApi->mute_host: #{e}"
end

Réactiver un host

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

Présentation

Réactive un host. Cet endpoint ne prend aucun argument JSON.

Arguments

Paramètres du chemin

Nom

Type

Description

host_name [required]

string

Name of the host to unmute.

Réponse

OK

Response with the list of muted host for your organization.

Expand All

Champ

Type

Description

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

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Exemple de code


                                        # Path parameters
export host_name="CHANGE_ME"
# Curl command curl -X POST "https://api.datadoghq.eu"https://api.datadoghq.com/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(ctx, 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 java.util.*;
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 = apiInstance.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();
        }
    }
}
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import hosts_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = hosts_api.HostsApi(api_client)
    host_name = "host_name_example" # str | Name of the host to unmute.

    # example passing only required values which don't have defaults set
    try:
        # Unmute a host
        api_response = api_instance.unmute_host(host_name)
        pprint(api_response)
    except datadog_api_client.v1.ApiException as e:
        print("Exception when calling HostsApi->unmute_host: %s\n" % e)
# load the gem
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V1::HostsApi.new
host_name = 'host_name_example' # String | Name of the host to unmute.

begin
  #Unmute a host
  result = api_instance.unmute_host(host_name)
  p result
rescue DatadogAPIClient::V1::ApiError => e
  puts "Exception when calling HostsApi->unmute_host: #{e}"
end