1. Architecture #
The components.
Components #
| Component | Role |
|---|---|
| Agent (DaemonSet) | One per node: node and container metrics, container logs, trace reception |
| Cluster Agent | Queries the Kubernetes API once for the whole cluster (instead of each agent), distributes cluster checks, provides external metrics for the HPA, hosts the admission controller |
| Datadog Operator | Manages the agent and Cluster Agent from a DatadogAgent resource |
2. Installing with the Operator #
Declarative.
Installation #
helm repo add datadog https://helm.datadoghq.com && helm repo update
helm install datadog-operator datadog/datadog-operator
kubectl create secret generic datadog-secret --from-literal api-key="$DD_API_KEY"apiVersion: datadoghq.com/v2alpha1
kind: DatadogAgent
metadata:
name: datadog
spec:
global:
clusterName: prod-eu
site: datadoghq.eu
credentials:
apiSecret: { secretName: datadog-secret, keyName: api-key }
features:
logCollection: { enabled: true, containerCollectAll: true }
apm:
instrumentation: { enabled: true } # injection automatique des bibliothèques APM
liveProcessCollection: { enabled: true }
orchestratorExplorer: { enabled: true }Good to know: The datadog/datadog Helm chart remains an alternative; the Operator has the advantage of a single resource, validated and easy to version with GitOps.3. Autodiscovery #
Monitoring whatever arrives.
Annotations #
Autodiscovery applies a check configuration to each matching container as soon as it starts. The configuration is set as annotations on the pod:
metadata:
annotations:
ad.datadoghq.com/redis.checks: |
{ "redisdb": { "instances": [ { "host": "%%host%%", "port": "6379" } ] } }
ad.datadoghq.com/redis.logs: '[{"source": "redis", "service": "cache"}]'
labels:
tags.datadoghq.com/env: prod
tags.datadoghq.com/service: cache
tags.datadoghq.com/version: "7.2"Good practice: The tags.datadoghq.com/* labels apply unified tagging to the pod's metrics, logs and traces: it is the first thing to standardize in your charts.4. Troubleshooting #
Useful commands.
Commands #
kubectl exec -it ds/datadog-agent -- agent status # état des checks, logs, APM
kubectl exec -it ds/datadog-agent -- agent configcheck # configurations Autodiscovery résolues
kubectl exec -it deploy/datadog-cluster-agent -- datadog-cluster-agent status| Symptom | Common cause |
|---|---|
| No container logs | containerCollectAll disabled, or /var/log/pods path not mounted |
| Check not running | Container name different from the one in the ad.datadoghq.com/<container> annotation |
| Duplicate metrics | Cluster check run by every agent instead of the Cluster Agent |
