Guide showing how to deploy Datadog to a k3d Kubernetes cluster, configure API key and operator, instrument a Node.js app, generate traffic, and view metrics logs traces
Welcome to the Datadog data ingestion lesson from the Datadog migration course at KodeKloud. This guide explains how Datadog collects and sends telemetry from your environment and applications to the Datadog platform. You’ll see how Datadog components are deployed to a local k3d Kubernetes cluster, how authentication is configured, how to instrument a Node.js app with tracing and logs, and how to generate traffic to observe telemetry in Datadog (metrics, logs, traces, and profiling).Key topics covered:
Datadog Kubernetes UI overview
Local k3d environment (k3s running in Docker)
Datadog components in Kubernetes (Agent, Cluster Agent, Operator)
Installing Datadog via Helm and creating the API key secret
DatadogAgent CR example (operator-based install)
Instrumenting a Node.js app with dd-trace
Building the Docker image and deploying the app pod
Generating traffic with k6 and viewing logs/traces in Datadog
From the Datadog console (this demo uses the US5 site), the Infrastructure → Kubernetes Overview gives a concise, high-level view of connected clusters. Clicking a cluster updates dashboards to show counts for clusters, namespaces, nodes, deployments, pods, containers, ReplicaSets, and Services.
The Kubernetes overview shows useful cluster metrics and summary tiles.
Scrolling in the Kubernetes overview surfaces FinOps insights and application troubleshooting patterns (e.g., deployments with unavailable replicas, pods in symptomatic phases, container restarts, node and volume details).
Resource utilization dashboards help with capacity planning — CPU/memory usage, over-provisioned workloads, unbound volumes, and recommended dashboards.
This demo uses k3d, a lightweight tool that runs k3s inside Docker. Each k3d node is a Docker container, so docker ps (or k3d docker ps) shows Kubernetes nodes as containers.Example k3d help summary:
# Example k3d help summaryk3d --help# Available Commands (examples)# cluster Manage cluster(s)# node Manage node(s)# image Handle container images# version Show k3d and default k3s version
Example docker ps output for a k3d cluster:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES460856a03c1 ghcr.io/k3d-io/k3d-tools:5.8.3 "/app/k3d-tools noop" 12 minutes ago Up 12 minutes 0.0.0.0:52149->6443/tcp k3d-datadog-cluster-tools82f4a878a850 ghcr.io/k3d-io/k3d-proxy:5.8.3 "/bin/sh -c nginx-pr…" 4 days ago Up 12 minutes 0.0.0.0:52148->80/tcp k3d-datadog-cluster-serverlbc73a12740bec rancher/k3s:v1.31.5-k3s1 "/bin/k3d-entrypoint…" 4 days ago Up 12 minutes 0.0.0.0:52147->6443/tcp k3d-datadog-cluster-agent-1754962cb41 rancher/k3s:v1.31.5-k3s1 "/bin/k3d-entrypoint…" 4 days ago Up 12 minutes 0.0.0.0:52146->6443/tcp k3d-datadog-cluster-agent-0ce256fc721 rancher/k3s:v1.31.5-k3s1 "/bin/k3d-entrypoint…" 4 days ago Up 12 minutes 0.0.0.0:52145->6443/tcp k3d-datadog-cluster-server-0
From inside the cluster, use kubectl to list nodes and pods:
kubectl get nodes# NAME STATUS ROLES AGE VERSION# k3d-datadog-cluster-agent-0 Ready <none> 4d7h v1.31.5+k3s1# k3d-datadog-cluster-agent-1 Ready <none> 4d7h v1.31.5+k3s1# k3d-datadog-cluster-server-0 Ready control-plane,master 4d7h v1.31.5+k3s1
You can install the chart either before or after creating the Kubernetes secret that contains the Datadog API key, but the Agent requires credentials to authenticate and send telemetry.
clusterName — how the cluster will appear in Datadog.
site — Datadog site/region (e.g., us5.datadoghq.com).
credentials.secret — Kubernetes secret name/key that contains the API key.
features — enable orchestratorExplorer, logCollection, apm, and profiling.
Apply the DatadogAgent manifest:
kubectl apply -f datadog-agent.yaml
If the Agents start without a valid secret or with an incorrect secret reference, they will fail to authenticate. Use kubectl logs on the Agent pods to diagnose authentication errors.
Ensure the secret name and key in the DatadogAgent manifest match the actual Kubernetes secret. Missing or incorrect API key references will prevent the Agent from sending telemetry.
This demo uses a simple Node.js REST API with three routes. To enable Datadog tracing for Node.js, install dd-trace and initialize it as early as possible — before other imports or application initialization.
Always require and initialize dd-trace at the top of your application entrypoint (before requiring frameworks like express) so auto-instrumentation captures requests and internal spans.
Example index.js (tracing + basic routes):
const tracer = require('dd-trace').init();const express = require('express');const app = express();const port = 80;app.get('/', (req, res) => { console.log('Request received at root route'); res.send('Hello, World!');});app.get('/route1', (req, res) => { console.error('Error simulated on route 1'); sum(); subtraction(); res.send('This is route 1');});app.get('/route2', (req, res) => { console.warn('Warn log on route 2'); subtraction(); res.send('This is route 2');});app.listen(port, () => { console.log(`Server is running on http://localhost:${port}`);});function sum() { let a = 10; let b = 20; return a + b;}function subtraction() { let a = 20; let b = 10; return a - b;}
The Datadog Agent forwards logs and receives traces (APM) on port 8126. After generating traffic, you can inspect application logs and traces in Datadog.Logs Explorer (filter by service, host, or container) shows timestamp, host, service, content, and extracted severity levels (info/warn/error).
Use the left sidebar filters to narrow logs to your node-app service or to a specific host/container.
Click into an application log to see extracted fields and severity. The example below shows an error emitted by route1 in the Node.js app.
APM → Trace Explorer displays traces composed of spans (Express handlers, DB calls, HTTP calls, etc.). Click a trace to view span breakdowns, attributes (environment, user agent, route, status code), and timings. This example shows a GET /route2 trace.
Traces are critical for distributed systems — they reveal service call flows, span durations, and where latencies or errors occur.
Deploy and validate Datadog components (Agent, Cluster Agent, Operator) in Kubernetes and verify daemonsets/pods.
Create a Kubernetes secret for the Datadog API key and reference it in the DatadogAgent configuration.
Instrument a Node.js application with dd-trace (initialize at the top of the entrypoint) and include the tracer in the Docker image.
Configure the application pod with environment variables so the Agent can collect traces, logs, and profiles.
Generate traffic with k6 and observe logs/traces inside Datadog.
Final dashboard view:
Follow these steps — install the Helm chart or operator, create the API key secret, apply the DatadogAgent CR (if using the operator), instrument your app, and generate traffic — to capture rich telemetry in Datadog: metrics, logs, traces, and profiles for monitoring and troubleshooting.Links and references