Etiquetas

El endpoint de etiquetas permite asignar etiquetas a hosts, por ejemplo: role:database. Esas etiquetas se aplican a todas las métricas enviadas por el host. Consulta hosts por su nombre (yourhost.example.com) cuando busques y apliques etiquetas a un host concreto.

El componente de tu infraestructura responsable de una etiqueta se identifica por una fuente. Por ejemplo, algunas fuentes válidas incluyen nagios, hudson, jenkins, users, feed, chef, puppet, git, bitbucket, fabric, capistrano, etc.

Más información sobre etiquetas en Empezando con etiquetas.

GET https://api.ap1.datadoghq.com/api/v1/tags/hostshttps://api.datadoghq.eu/api/v1/tags/hostshttps://api.ddog-gov.com/api/v1/tags/hostshttps://api.datadoghq.com/api/v1/tags/hostshttps://api.us3.datadoghq.com/api/v1/tags/hostshttps://api.us5.datadoghq.com/api/v1/tags/hosts

Información general

Devuelve una asignación de etiquetas a hosts para toda tu infraestructura.

Argumentos

Cadenas de consulta

Nombre

Tipo

Descripción

source

string

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

Respuesta

OK

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

Expand All

Campo

Tipo

Descripción

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

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Not Found

Error response object.

Expand All

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Too many requests

Error response object.

Expand All

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Ejemplo de código

"""
Get Tags returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.tags_api import TagsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = TagsApi(api_client)
    response = api_instance.list_host_tags()

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"

GET https://api.ap1.datadoghq.com/api/v1/tags/hosts/{host_name}https://api.datadoghq.eu/api/v1/tags/hosts/{host_name}https://api.ddog-gov.com/api/v1/tags/hosts/{host_name}https://api.datadoghq.com/api/v1/tags/hosts/{host_name}https://api.us3.datadoghq.com/api/v1/tags/hosts/{host_name}https://api.us5.datadoghq.com/api/v1/tags/hosts/{host_name}

Información general

Devuelve la lista de etiquetas que se aplican a un host determinado.

Argumentos

Parámetros de ruta

Nombre

Tipo

Descripción

host_name [required]

string

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

Cadenas de consulta

Nombre

Tipo

Descripción

source

string

Source to filter.

Respuesta

OK

Set of tags to associate with your host.

Expand All

Campo

Tipo

Descripción

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

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Not Found

Error response object.

Expand All

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Too many requests

Error response object.

Expand All

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Ejemplo de código

"""
Get host tags returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.tags_api import TagsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = TagsApi(api_client)
    response = api_instance.get_host_tags(
        host_name="host_name",
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"

POST https://api.ap1.datadoghq.com/api/v1/tags/hosts/{host_name}https://api.datadoghq.eu/api/v1/tags/hosts/{host_name}https://api.ddog-gov.com/api/v1/tags/hosts/{host_name}https://api.datadoghq.com/api/v1/tags/hosts/{host_name}https://api.us3.datadoghq.com/api/v1/tags/hosts/{host_name}https://api.us5.datadoghq.com/api/v1/tags/hosts/{host_name}

Información general

Este endpoint permite añadir nuevas etiquetas a un host, especificando opcionalmente de dónde proceden estas etiquetas).

Argumentos

Parámetros de ruta

Nombre

Tipo

Descripción

host_name [required]

string

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

Cadenas de consulta

Nombre

Tipo

Descripción

source

string

Solicitud

Body Data (required)

Actualiza el cuerpo de una solicitud de etiquetas de hosts.

Expand All

Campo

Tipo

Descripción

host

string

Your host name.

tags

[string]

A list of tags to apply to the host.

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

Respuesta

Created

Set of tags to associate with your host.

Expand All

Campo

Tipo

Descripción

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

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Not Found

Error response object.

Expand All

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Too many requests

Error response object.

Expand All

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Ejemplo de código

"""
Add tags to a host returns "Created" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.tags_api import TagsApi
from datadog_api_client.v1.model.host_tags import HostTags

body = HostTags(
    host="test.host",
    tags=[
        "environment:production",
    ],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = TagsApi(api_client)
    response = api_instance.create_host_tags(host_name="host_name", body=body)

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"

PUT https://api.ap1.datadoghq.com/api/v1/tags/hosts/{host_name}https://api.datadoghq.eu/api/v1/tags/hosts/{host_name}https://api.ddog-gov.com/api/v1/tags/hosts/{host_name}https://api.datadoghq.com/api/v1/tags/hosts/{host_name}https://api.us3.datadoghq.com/api/v1/tags/hosts/{host_name}https://api.us5.datadoghq.com/api/v1/tags/hosts/{host_name}

Información general

Este endpoint te permite actualizar/sustituir todas las etiquetas en una fuente de integraciones con aquellas proporcionadas en la solicitud.

Argumentos

Parámetros de ruta

Nombre

Tipo

Descripción

host_name [required]

string

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

Cadenas de consulta

Nombre

Tipo

Descripción

source

string

The source of the tags (for example chef, puppet). Complete list of source attribute values

Solicitud

Body Data (required)

Añadir etiquetas a hosts

Expand All

Campo

Tipo

Descripción

host

string

Your host name.

tags

[string]

A list of tags to apply to the host.

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

Respuesta

OK

Set of tags to associate with your host.

Expand All

Campo

Tipo

Descripción

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

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Not Found

Error response object.

Expand All

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Too many requests

Error response object.

Expand All

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Ejemplo de código

"""
Update host tags returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.tags_api import TagsApi
from datadog_api_client.v1.model.host_tags import HostTags

body = HostTags(
    host="test.host",
    tags=[
        "environment:production",
    ],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = TagsApi(api_client)
    response = api_instance.update_host_tags(host_name="host_name", body=body)

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"

DELETE https://api.ap1.datadoghq.com/api/v1/tags/hosts/{host_name}https://api.datadoghq.eu/api/v1/tags/hosts/{host_name}https://api.ddog-gov.com/api/v1/tags/hosts/{host_name}https://api.datadoghq.com/api/v1/tags/hosts/{host_name}https://api.us3.datadoghq.com/api/v1/tags/hosts/{host_name}https://api.us5.datadoghq.com/api/v1/tags/hosts/{host_name}

Información general

Este endpoint te permite eliminar todas las etiquetas asignadas a usuarios para un único host.

Argumentos

Parámetros de ruta

Nombre

Tipo

Descripción

host_name [required]

string

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

Cadenas de consulta

Nombre

Tipo

Descripción

source

string

The source of the tags (for example chef, puppet). Complete list of source attribute values.

Respuesta

OK

Forbidden

Error response object.

Expand All

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Not Found

Error response object.

Expand All

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Too many requests

Error response object.

Expand All

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Ejemplo de código

"""
Remove host tags returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.tags_api import TagsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = TagsApi(api_client)
    api_instance.delete_host_tags(
        host_name="host_name",
    )

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"