Skip to content

datadog get-hosts

Allows searching for hosts by name, alias, or tag. Hosts live within the past 3 hours are included by default

Description

Allows searching for hosts by name, alias, or tag. Hosts live within the past 3 hours are included by default

Synopsis

datadog get-hosts
    [--site <site>]
    [--filter <filter>]
    [--sort_field <sort_field>]
    [--sort_dir <sort_dir>]
    [--start <start>]
    [--count <count>]
    [--from <from>]
    [--include_muted_hosts_data]
    [--include_hosts_metadata]

Arguments

site - (string)

     Site where this command will be executed
     Example: --site "site-1"
     Default: input.site      Attributes: optional

filter - (string)

     String to filter search results
     Example: --filter "filter-1"
     Default: _None_      Attributes: optional

sort_field - (string)

     Sort hosts by this field
     Example: --sort_field "sort_field-1"
     Default: _None_      Attributes: optional

sort_dir - (string)

     Direction of sort
     Example: --sort_dir "sort_dir-1"
     Default: _None_      Attributes: optional

     Validation:
         allowed values: asc, desc

start - (int)

     Host result to start search from
     Example: --start 1
     Default: _None_      Attributes: optional

count - (int)

     Number of hosts to return. Max 1000
     Example: --count 1
     Default: _None_      Attributes: optional

from - (time)

     time from which you want to search your hosts
     Example: --from "2019-10-12T07:20:50.52Z"
     Default: 1 hour ago      Attributes: optional

include_muted_hosts_data - (bool)

     Include information on the muted status of hosts and when the mute expires
     Example: --include_muted_hosts_data
     Default: _None_      Attributes: optional

include_hosts_metadata - (bool)

     Include additional metadata about the hosts (agent_version, machine, platform, processor, etc.)
     Example: --include_hosts_metadata
     Default: false      Attributes: optional

Examples

Input:

!datadog get-hosts 
Output:
ID      NAME        ALIASES     MUTED   SOURCES
8847988 BHCP-131    BHCP-131    false   agent

Access Control

To use this command, you need access to the following:

Field Value
Action "read"
Service Type "datadog"
Service Instance
Namespace
Object Type "host"
Object ID

Please see Access Control for details.