RousselTMLEARNING

Observability

Datadog on Kubernetes: Operator, Cluster Agent and Autodiscovery

Monitor Kubernetes with Datadog: the Datadog Operator and the DatadogAgent resource, Cluster Agent, annotation-based Autodiscovery, container log collection, automatic APM instrumentation (Single Step) and troubleshooting.

1. Architecture #

The components.

Components #

Datadog on Kubernetes
ComponentRole
Agent (DaemonSet)One per node: node and container metrics, container logs, trace reception
Cluster AgentQueries 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 OperatorManages 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
SymptomCommon cause
No container logscontainerCollectAll disabled, or /var/log/pods path not mounted
Check not runningContainer name different from the one in the ad.datadoghq.com/<container> annotation
Duplicate metricsCluster check run by every agent instead of the Cluster Agent

Related articles

Time-based vs event-based SLO: understanding, computing and choosing (with the Qonto example)

Differences between time-based SLOs (time slices, uptime) and event-based SLOs (good events over total): defi…

The observability trilemma: cost, completeness and performance, and how solutions resolve it

Understanding the observability trilemma (cost, data completeness, query performance), its three trade-offs, …

Datadog platform architecture: sites, organizations, keys and data model

Understand Datadog's architecture: data sources (agent, cloud integrations, SDKs, OpenTelemetry), regional si…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!