Skip to content

Instantly share code, notes, and snippets.

@devops-school
Created April 20, 2026 23:20
Show Gist options
  • Select an option

  • Save devops-school/782597b7699fdd82f35668175eeb7e83 to your computer and use it in GitHub Desktop.

Select an option

Save devops-school/782597b7699fdd82f35668175eeb7e83 to your computer and use it in GitHub Desktop.
Datadog Project - Application Setup with Datadog Configurations

Note - You need to do the project without much trainer help.

I’ve packaged a ready-to-use beginner lab with working code and a simple README: [Download the starter project ZIP] - https://github.com/devopsschool-assignment-projects/datadog-starter-lab-python-app [View the README] - https://github.com/devopsschool-assignment-projects/datadog-starter-lab-python-app [View the Flask app]- https://github.com/devopsschool-assignment-projects/datadog-starter-lab-python-app

What students will build

A tiny Ubuntu-hosted web app with:

  • /health
  • /api/items
  • /slow
  • /error
  • one simple HTML page for RUM

Then they will connect it to:

  • Datadog Agent
  • Infra Monitoring
  • APM
  • Logs
  • Synthetic Monitoring
  • RUM
  • Alerts
  • Dashboard
  • API

Datadog’s docs support this exact flow: install the Agent on Linux, enable traces, turn on log collection in datadog.yaml, add a custom log file config under conf.d, create Browser RUM with a clientToken and applicationId, add Synthetic API assertions like status code and response time, and use API/Application keys for API access. ([Datadog][1])

Exact student steps

1) Prepare Ubuntu

Run this:

sudo apt update
sudo apt install -y python3 python3-venv python3-pip curl unzip

Flask’s official docs support installing Flask with pip inside a virtual environment. ([Flask Documentation][2])

2) Unzip the project

Copy datadog-starter-lab.zip to the Ubuntu machine, then run:

mkdir -p ~/datadog-lab
cd ~/datadog-lab
unzip datadog-starter-lab.zip
cd datadog-starter-lab

3) Create Python environment and install packages

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

4) Prepare app log folder

sudo mkdir -p /var/log/studentapp
sudo chown -R $USER:$USER /var/log/studentapp

5) Install Datadog Agent on Ubuntu

For a Linux host, Datadog’s tutorial shows this install pattern; replace the API key and adjust DD_SITE if your org is not on datadoghq.com. ([Datadog][3])

DD_AGENT_MAJOR_VERSION=7 DD_API_KEY=YOUR_DATADOG_API_KEY DD_SITE="datadoghq.com" bash -c "$(curl -L https://install.datadoghq.com/scripts/install_script_agent7.sh)"

Start it:

sudo service datadog-agent start
sudo datadog-agent status

Datadog’s docs say Linux Agent install is done with the generated Linux script, and their tracing tutorial shows sudo service datadog-agent start on Linux. ([Datadog][1])

6) Enable log collection in the Agent

Datadog says log collection is not enabled by default and you must set logs_enabled: true in datadog.yaml. ([Datadog][4])

Edit:

sudo nano /etc/datadog-agent/datadog.yaml

Find this line and change it to:

logs_enabled: true

7) Tell Datadog Agent to read the app log file

Datadog’s host log docs say to create a new folder under conf.d/, place a conf.yaml there, then restart the Agent. ([Datadog][5])

Run:

sudo mkdir -p /etc/datadog-agent/conf.d/studentapp.d
sudo nano /etc/datadog-agent/conf.d/studentapp.d/conf.yaml

Paste this:

logs:
  - type: file
    path: /var/log/studentapp/app.log
    service: studentapp
    source: python

Restart the Agent:

sudo systemctl restart datadog-agent
sudo datadog-agent status

Datadog also notes that on Linux the Agent runs as the datadog-agent user, so log file permissions matter. ([Datadog][6])

8) Run the app with APM enabled

Datadog’s Python tracing docs support starting a Python app with ddtrace-run, and DD_SERVICE / DD_VERSION are valid config env vars for framework integrations like Flask. ([Datadog][7])

Run:

source venv/bin/activate

export DD_SERVICE=studentapp
export DD_ENV=lab
export DD_VERSION=1.0.0
export DD_LOGS_INJECTION=true
export DD_AGENT_HOST=127.0.0.1

ddtrace-run python3 app.py

9) Open the app

On the Ubuntu machine:

curl http://127.0.0.1:5000/health

In a browser:

http://YOUR_UBUNTU_IP:5000/

10) Generate traffic for APM and Logs

Open another terminal and run:

for i in {1..10}; do curl -s http://127.0.0.1:5000/ > /dev/null; done
for i in {1..5}; do curl -s http://127.0.0.1:5000/api/items > /dev/null; done
for i in {1..3}; do curl -s http://127.0.0.1:5000/slow > /dev/null; done
for i in {1..2}; do curl -s http://127.0.0.1:5000/error > /dev/null; done

Now students should see:

  • host metrics from the Agent
  • traces for the Flask app
  • logs from /var/log/studentapp/app.log

Datadog’s APM getting-started flow is: set up tracing, run the app, generate traffic, then explore collected traces. ([Datadog][8])

Exact RUM setup

Datadog’s Browser RUM docs say you first create a JS application in Datadog, which generates a clientToken and an applicationId, then add the SDK snippet to the page. ([Datadog][9])

11) Create the RUM app in Datadog

In Datadog UI:

  • Go to Digital Experience

  • Click Add an Application

  • Choose JavaScript (JS)

  • Create the app

  • Copy:

    • clientToken
    • applicationId

12) Restart the app with RUM enabled

source venv/bin/activate

export DD_SERVICE=studentapp
export DD_ENV=lab
export DD_VERSION=1.0.0
export DD_LOGS_INJECTION=true
export DD_AGENT_HOST=127.0.0.1

export DD_RUM_ENABLED=true
export DD_CLIENT_TOKEN=YOUR_CLIENT_TOKEN
export DD_APPLICATION_ID=YOUR_APPLICATION_ID
export DD_SITE=datadoghq.com

ddtrace-run python3 app.py

The supplied index.html already contains the Datadog Browser RUM snippet. After that, page loads, user interactions, and frontend performance data can appear in RUM. ([Datadog][9])

Exact Synthetic Monitoring step

Datadog’s HTTP API test docs say API tests can assert things like status code and response time. ([Datadog][10])

Create one Synthetic API test:

  • Type: HTTP

  • URL: http://YOUR_UBUNTU_IP:5000/health

  • Assertions:

    • status code = 200
    • response time < 2000 ms

Exact Monitor tasks

Ask students to create these 2 monitors:

  1. CPU monitor on the Ubuntu host
  2. Synthetic failure monitor for /health

Datadog’s monitor docs cover metric threshold monitors, and Synthetics results can also be used operationally for alerting. ([Datadog][11])

Exact Dashboard tasks

Ask students to create one dashboard called:

Student App Observability

Add widgets for:

  • CPU
  • Memory
  • request count
  • latency
  • error count
  • log stream
  • Synthetic result

Datadog dashboards are intended for combining these telemetry views in one place. ([Datadog][12])

Exact API task

Datadog’s API docs say:

  • write requests need an API key
  • read requests also need an Application key
  • headers are DD-API-KEY and DD-APPLICATION-KEY ([Datadog][13])

Give students this exact example:

export DD_API_KEY=YOUR_API_KEY
export DD_APP_KEY=YOUR_APPLICATION_KEY

curl -X GET "https://api.datadoghq.com/api/v1/dashboard/lists/manual" \
  -H "Accept: application/json" \
  -H "DD-API-KEY: ${DD_API_KEY}" \
  -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"

If they use EU instead of US1, use the Datadog EU API host instead. Datadog’s auth docs note that API hosts vary by site. ([Datadog][13])

What students should submit

Have each team submit:

  • screenshot of Infrastructure host
  • screenshot of APM traces
  • screenshot of Logs Explorer
  • screenshot of RUM
  • screenshot of Synthetic test
  • screenshot of 2 monitors
  • screenshot of dashboard
  • output of the curl API command

Teacher note

Send to an email to DevOps@rajeshkumar.xyz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment