Skip to main content

host_tags

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

Overview

Namehost_tags
TypeResource
Iddatadog.infrastructure.host_tags

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
hoststringYour host name. (example: test.host)
tagsarrayA list of tags associated with a host.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_host_tagsselecthost_namesourceReturn the list of tags that apply to a given host.
list_host_tagsselectsourceReturns a mapping of tags to hosts. For each tag, the response returns a list of host names that contain this tag. There is a restriction of 10k total host names from the org that can be attached to tags and returned.
create_host_tagsinserthost_namesourceThis endpoint allows you to add new tags to a host,<br />optionally specifying what source these tags come from. If tags already exist, appends new tags to the tag list. If no source is specified, defaults to "user".
update_host_tagsreplacehost_namesourceThis endpoint allows you to update/replace all tags in<br />an integration source with those supplied in the request.
delete_host_tagsdeletehost_namesourceThis endpoint allows you to remove all tags<br />for a single host. If no source is specified, only deletes from the source "User".

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_namestringSpecified host name to delete tags
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.
sourcestringSource of the tags to be deleted. [Complete list of source attribute values](https:​//docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). Use "user" source for custom-defined tags.

SELECT examples

Return the list of tags that apply to a given host.

SELECT
host,
tags
FROM datadog.infrastructure.host_tags
WHERE host_name = '{{ host_name }}' -- required
AND source = '{{ source }}'
;

INSERT examples

This endpoint allows you to add new tags to a host,<br />optionally specifying what source these tags come from. If tags already exist, appends new tags to the tag list. If no source is specified, defaults to "user".

INSERT INTO datadog.infrastructure.host_tags (
host,
tags,
host_name,
source
)
SELECT
'{{ host }}',
'{{ tags }}',
'{{ host_name }}',
'{{ source }}'
RETURNING
host,
tags
;

REPLACE examples

This endpoint allows you to update/replace all tags in<br />an integration source with those supplied in the request.

REPLACE datadog.infrastructure.host_tags
SET
host = '{{ host }}',
tags = '{{ tags }}'
WHERE
host_name = '{{ host_name }}' --required
AND source = '{{ source}}'
RETURNING
host,
tags;

DELETE examples

This endpoint allows you to remove all tags<br />for a single host. If no source is specified, only deletes from the source "User".

DELETE FROM datadog.infrastructure.host_tags
WHERE host_name = '{{ host_name }}' --required
AND source = '{{ source }}'
;