Tags
Security Monitoring is now available Security Monitoring is now available

Tags

The tag endpoint allows you to tag hosts with keywords meaningful to you, like role:database. All metrics sent from a host have its tags applied. When fetching and applying tags to a particular host, refer to hosts by name (yourhost.example.com).

The component of your infrastructure responsible for a tag is identified by a source. For example, some valid sources include nagios, hudson, jenkins, users, feed, chef, puppet, git, bitbucket, fabric, capistrano, etc.

Read more about tags on the dedicated documentation page.

Add tags to a host

post https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/tags/hosts/{host_name}

Overview

This endpoint allows you to add new tags to a host, optionally specifying where these tags come from.

Arguments

Path Parameters

Name

Type

Description

host_name [required]

string

This endpoint allows you to add new tags to a host, optionally specifying where the tags came from.

Query Strings

Name

Type

Description

source

string

Request

Body Data (required)

Update host tags request body.

Expand All

Field

Type

Description

host

string

Your host name.

tags

[string]

A list of tags to apply to the host.

{
  "host": "test.host",
  "tags": [
    "environment:production"
  ]
}

Response

Created

Set of tags to associate with your host.

Expand All

Field

Type

Description

host

string

Your host name.

tags

[string]

A list of tags to apply to the host.

{
  "host": "test.host",
  "tags": [
    "environment:production"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Not Found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


                                        # Path parameters
export host_name="CHANGE_ME"
# Curl command curl -X post https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/tags/hosts/${host_name} \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \ -d @- << EOF {} EOF

Get host tags

get https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/tags/hosts/{host_name}

Overview

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

Arguments

Path Parameters

Name

Type

Description

host_name [required]

string

When specified, filters list of tags to those tags with the specified source.

Query Strings

Name

Type

Description

source

string

Source to filter.

Response

OK

Set of tags to associate with your host.

Expand All

Field

Type

Description

host

string

Your host name.

tags

[string]

A list of tags to apply to the host.

{
  "host": "test.host",
  "tags": [
    "environment:production"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Not Found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


                                        # Path parameters
export host_name="CHANGE_ME"
# Curl command curl -X get https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/tags/hosts/${host_name} \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"

Get Tags

get https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/tags/hosts

Overview

Return a mapping of tags to hosts for your whole infrastructure.

Arguments

Query Strings

Name

Type

Description

source

string

When specified, filters host list to those tags with the specified source.

Response

OK

In this object, the key is the tag, the value is a list of host names that are reporting that tag.

Expand All

Field

Type

Description

tags

object

A list of tags to apply to the host.

<any-key>

[string]

A list of additional properties for tags.

{
  "tags": {
    "<any-key>": [
      "test.metric.host"
    ]
  }
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Not Found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


                                        # Curl command
curl -X get https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/tags/hosts \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"

                                        

Remove host tags

delete https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/tags/hosts/{host_name}

Overview

This endpoint allows you to remove all user-assigned tags for a single host.

Arguments

Path Parameters

Name

Type

Description

host_name [required]

string

This endpoint allows you to remove all user-assigned tags for a single host.

Query Strings

Name

Type

Description

source

string

The source of the tags (e.g. chef, puppet). Complete list of source attribute values.

Response

OK

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Not Found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


                                        # Path parameters
export host_name="CHANGE_ME"
# Curl command curl -X delete https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/tags/hosts/${host_name} \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"

Update host tags

put https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/tags/hosts/{host_name}

Overview

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

Arguments

Path Parameters

Name

Type

Description

host_name [required]

string

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

Query Strings

Name

Type

Description

source

string

The source of the tags (e.g. chef, puppet). Complete list of source attribute values

Request

Body Data (required)

Add tags to host

Expand All

Field

Type

Description

host

string

Your host name.

tags

[string]

A list of tags to apply to the host.

{
  "host": "test.host",
  "tags": [
    "environment:production"
  ]
}

Response

OK

Set of tags to associate with your host.

Expand All

Field

Type

Description

host

string

Your host name.

tags

[string]

A list of tags to apply to the host.

{
  "host": "test.host",
  "tags": [
    "environment:production"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Not Found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


                                        # Path parameters
export host_name="CHANGE_ME"
# Curl command curl -X put https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/tags/hosts/${host_name} \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \ -d @- << EOF {} EOF