Skip to main content

hosts

Creates, updates, deletes, gets or lists a hosts resource.

Overview

Namehosts
TypeResource
Iddatadog.infrastructure.hosts

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idinteger (int64)The host ID.
namestringThe host name. (example: i-hostname)
aws_namestringAWS name of your host. (example: mycoolhost-1)
host_namestringThe host name. (example: i-deadbeef)
aliasesarrayHost aliases collected by Datadog.
appsarrayThe Datadog integrations reporting metrics for the host.
is_mutedbooleanIf a host is muted or unmuted.
last_reported_timeinteger (int64)Last time the host reported a metric data point.
metaobjectMetadata associated with your host.
metricsobjectHost Metrics collected.
mute_timeoutinteger (int64)Timeout of the mute applied to your host.
sourcesarraySource or cloud provider associated with your host.
tags_by_sourceobjectList of tags for each source (AWS, Datadog Agent, Chef..).
upbooleanDisplays UP when the expected metrics are received and displays ??? if no metrics are received.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_hostsselectfilter, sort_field, sort_dir, start, count, from, include_muted_hosts_data, include_hosts_metadataThis endpoint allows searching for hosts by name, alias, or tag.<br />Hosts live within the past 3 hours are included by default.<br />Retention is 7 days.<br />Results are paginated with a max of 1000 results at a time.<br />Note: If the host is an Amazon EC2 instance, id is replaced with aws_id in the response.<br />Note: To enrich the data returned by this endpoint with security scans, see the new [api/v2/security/scanned-assets-metadata](https:​//docs.datadoghq.com/api/latest/security-monitoring/#list-scanned-assets-metadata) endpoint.
mute_hostexechost_nameMute a host. Note: This creates a [Downtime V2](https:​//docs.datadoghq.com/api/latest/downtimes/#schedule-a-downtime) for the host.
unmute_hostexechost_nameUnmutes a host. This endpoint takes no JSON arguments.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
host_namestringName of the host to unmute.
sitestringThe Datadog site (region) for your organization, for example datadoghq.com, us3.datadoghq.com, us5.datadoghq.com, ap1.datadoghq.com, ap2.datadoghq.com, datadoghq.eu, ddog-gov.com. Resolved from the DD_SITE environment variable when set. Optional: defaults to datadoghq.com, or the value of the DD_SITE environment variable when set; a WHERE value overrides both.
countinteger (int64)Number of hosts to return. Max 1000.
filterstringString to filter search results.
frominteger (int64)Number of seconds since UNIX epoch from which you want to search your hosts.
include_hosts_metadatabooleanInclude additional metadata about the hosts (agent_version, machine, platform, processor, etc.).
include_muted_hosts_databooleanInclude information on the muted status of hosts and when the mute expires.
sort_dirstringDirection of sort. Options include asc and desc.
sort_fieldstringSort hosts by this field.
startinteger (int64)Specify the starting point for the host search results. For example, if you set count to 100 and the first 100 results have already been returned, you can set start to 101 to get the next 100 results.

SELECT examples

This endpoint allows searching for hosts by name, alias, or tag.<br />Hosts live within the past 3 hours are included by default.<br />Retention is 7 days.<br />Results are paginated with a max of 1000 results at a time.<br />Note: If the host is an Amazon EC2 instance, id is replaced with aws_id in the response.<br />Note: To enrich the data returned by this endpoint with security scans, see the new [api/v2/security/scanned-assets-metadata](https:​//docs.datadoghq.com/api/latest/security-monitoring/#list-scanned-assets-metadata) endpoint.

SELECT
id,
name,
aws_name,
host_name,
aliases,
apps,
is_muted,
last_reported_time,
meta,
metrics,
mute_timeout,
sources,
tags_by_source,
up
FROM datadog.infrastructure.hosts
WHERE filter = '{{ filter }}'
AND sort_field = '{{ sort_field }}'
AND sort_dir = '{{ sort_dir }}'
AND start = '{{ start }}'
AND count = '{{ count }}'
AND from = '{{ from }}'
AND include_muted_hosts_data = '{{ include_muted_hosts_data }}'
AND include_hosts_metadata = '{{ include_hosts_metadata }}'
;

Lifecycle Methods

EXEC variables use wire (API) names.

Mute a host. Note: This creates a Downtime V2 for the host.

EXEC datadog.infrastructure.hosts.mute_host
@host_name='{{ host_name }}' --required,
@@json=
'{
"end": {{ end }},
"message": "{{ message }}",
"override": {{ override }}
}'
;