host_tags
Creates, updates, deletes, gets or lists a host_tags resource.
Overview
| Name | host_tags |
| Type | Resource |
| Id | datadog.infrastructure.host_tags |
Fields
The following fields are returned by SELECT queries:
- get_host_tags
- list_host_tags
| Name | Datatype | Description |
|---|---|---|
host | string | Your host name. (example: test.host) |
tags | array | A list of tags associated with a host. |
| Name | Datatype | Description |
|---|---|---|
tags | object | A mapping of tags to host names |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_host_tags | select | host_name | source | Return the list of tags that apply to a given host. |
list_host_tags | select | source | Returns 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_tags | insert | host_name | source | 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". |
update_host_tags | replace | host_name | source | This endpoint allows you to update/replace all tags in<br />an integration source with those supplied in the request. |
delete_host_tags | delete | host_name | source | This 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.
| Name | Datatype | Description |
|---|---|---|
host_name | string | Specified host name to delete tags |
site | string | The 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. |
source | string | Source 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
- get_host_tags
- list_host_tags
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 }}'
;
Returns 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.
SELECT
tags
FROM datadog.infrastructure.host_tags
WHERE source = '{{ source }}'
;
INSERT examples
- create_host_tags
- Manifest
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
;
# Description fields are for documentation purposes
- name: host_tags
props:
- name: host_name
value: "{{ host_name }}"
description: Required parameter for the host_tags resource.
- name: host
value: "{{ host }}"
description: |
Your host name.
- name: tags
value:
- "{{ tags }}"
description: |
A list of tags associated with a host.
- name: source
value: "{{ source }}"
description: Source to add tags. [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. If no source is specified, defaults to "user". (example: chef)
description: Source to add tags. [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. If no source is specified, defaults to "user". (example: chef)
REPLACE examples
- update_host_tags
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
- delete_host_tags
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 }}'
;