Integration ConfigMap
Rapport de recherche Datadog : Bilan sur l'adoption de l'informatique sans serveur Rapport : Bilan sur l'adoption de l'informatique sans serveur

Integration ConfigMap

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.

To enable integrations, Datadog recommends that you use annotations in the manifest of your application. This is called Autodiscovery. For more details, see the Autodiscovery section. If you cannot use Autodiscovery, follow the alternatives below:

ConfigMap

It is possible to leverage a ConfigMap to configure or enable integrations. To do so, you only need to create a ConfigMap with the integration(s)’s configuration. Then, reference this ConfigMap among the volumes of your Agent’s manifest.

For example, in the following case we customize the name, url, and tags fields of the HTTP check. To enable other integrations, just specify the correct YAML name and make sure it is properly formated.

kind: ConfigMap
apiVersion: v1
metadata:
  name: dd-agent-config
  namespace: default
data:
  http-config: |-
    ad_identifiers:
      - httpd
      - my-custom-httpd
    init_config:
    instances:
    - name: My service
      url: my.service:port/healthz
      tags:
        - service:critical
---

And in the manifest of your Agent (DaemonSet/deployment) add the following:

[...]
        volumeMounts:
        [...]
          - name: dd-agent-config
            mountPath: /conf.d
      volumes:
      [...]
        - name: dd-agent-config
          configMap:
            name: dd-agent-config
            items:
            - key: http-config
              path: http_check.yaml
[...]

Note: See the Autodiscovery Container Identifier documentation for more information on using ad_identifiers to apply Autodiscovery configuration file templates to containers.

Mounting a custom configuration file in a container with a ConfigMap

To mount a custom datadog.yaml in a container with a ConfigMap, employ the following in your DaemonSet manifest:

[...]
        volumeMounts:
        [...]
          - name: confd-config
            mountPath: /conf.d
          - name: datadog-yaml
            mountPath: /etc/datadog-agent/datadog.yaml
            subPath: datadog.yaml
      volumes:
      [...]
        - name: confd-config
          configMap:
            name: dd-agent-config
            items:
              - key: http-config
                path: http_check.yaml
        - name: datadog-yaml
          configMap:
            name: dd-agent-config
            items:
              - key: datadog-yaml
                path: datadog.yaml
[...]

And in your ConfigMap:

kind: ConfigMap
apiVersion: v1
metadata:
  name: dd-agent-config
  namespace: default
data:
  http-config: |-
    init_config:
    instances:
  datadog-yaml: |-
    check_runners: 1
    listeners:
      - name: kubelet
    config_providers:
      - name: kubelet
        polling: true

Integrations enablement with Helm

The Datadog entrypoint copies files with a .yaml extension found in /conf.d and files with .py extension in /check.d to /etc/datadog-agent/conf.d and /etc/datadog-agent/checks.d respectively. The keys for datadog.confd and datadog.checksd should mirror the content found in their respective ConfigMaps, i.e.:

datadog:
  confd:
    redisdb.yaml: |-
      ad_identifiers:
        - redis
        - bitnami/redis
      init_config:
      instances:
        - host: "%%host%%"
          port: "%%port%%"
    jmx.yaml: |-
      ad_identifiers:
        - openjdk
      instance_config:
      instances:
        - host: "%%host%%"
          port: "%%port_0%%"

Further Reading

Documentation, liens et articles supplémentaires utiles: