Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

This document explains how to apply an Autodiscovery configuration template to a specific container. The ad_identifiers parameter can match a container image name or a custom identifier.

Container image name

To apply the following Autodiscovery configuration template to a given container, replace <AUTODISCOVERY_IDENTIFIER> with the short container image name:

ad_identifiers:
  <AUTODISCOVERY_IDENTIFIER>

init_config:
  <INIT_CONFIG>

instances:
  <INSTANCES_CONFIG>

Example: The following Apache Autodiscovery configuration template applies to a container image named httpd:

ad_identifiers:
  - httpd
init_config:
instances:
  - apache_status_url: http://%%host%%/server-status?auto
logs:
  source: apache
  service: webapp

This matches any httpd container image on your host. If you have one container running foo/httpd:latest and another running bar/httpd:v2, the Agent applies the above template to both containers.

When using short image names as Autodiscovery container identifiers, the Agent cannot distinguish between identically named images from different sources or with different tags.

Multiple identifiers

Specify multiple image names by adding to the ad_identifiers list, for example:

ad_identifiers:
  - httpd
  - my-custom-httpd-image

This matches any container images on your host that match httpd or my-custom-httpd-image.

Custom Autodiscovery container identifiers

If you want to apply different configuration templates to containers running the same image, use custom container identifiers.

  1. Supply a custom container identifier to your container using a Docker label or Kubernetes annotation.

    Example: Apply a Docker label or Kubernetes annotation to identify your container as foo:

    LABEL com.datadoghq.ad.check.id="foo"
    

    Note: The com.datadoghq.ad.check.id label takes precedence over the image name.

    ad.datadoghq.com/<CONTAINER_NAME>.check.id: 'foo'
    

    Replace <CONTAINER_NAME> with the container name within the pod.

    Note: Supported in Datadog Agent v6.25+ and v7.25. The ad.datadoghq.com/<CONTAINER_NAME>.check.id label takes precedence over the image name.

  2. Reference this custom value in your Autodiscovery configuration template.

    Example: The following Apache Autodiscovery configuration template designates a container image with the custom name foo:

    ad_identifiers:
      - foo
    init_config:
    instances:
      - apache_status_url: http://%%host%%/server-status?auto
    logs:
      source: apache
      service: webapp
    

Further Reading