Ravindra BagaleCourses & study guides मराठी

DevOps

Chapter 13: Monitoring Basics

Friends, today we learn monitoring. Think of a bike dashboard — speed, fuel, temperature — before you stop on the highway. Golden signals, host metrics (CPU/RAM/disk), and the primary path: Prometheus + Node Exporter + Grafana. A short CloudWatch mention — depth lives in the AWS course. Alert fatigue tip and a disk threshold lab. Do not fear: one clear dashboard + one useful alert.

What you will learn in this chapter

  • Golden signals in plain English
  • Host metrics: CPU, RAM and disk
  • Prometheus + Node Exporter primary path
  • A simple Grafana dashboard
  • One useful disk alert without noise

Concepts in this chapter

  1. 13.1Why monitor — dashboard before the outage call
  2. 13.2Golden signals — four questions in plain English
  3. 13.3Host metrics — CPU, RAM, disk
  4. 13.4Primary path — Prometheus + Node Exporter + Grafana
  5. 13.5Node Exporter — expose host metrics
  6. 13.6Prometheus — scrape and store
  7. 13.7Grafana — one calm dashboard
  8. 13.8Alerting — one disk threshold that matters
  9. 13.9What about application metrics?
  10. 13.10CloudWatch in one paragraph (secondary path)
  11. 13.11Anti-patterns
  12. 13.12Troubleshooting table
  13. 13.13Lab — disk metric path and a triggered alert

The chapter recap is at the end of the last concept page.

Practice Tasks

About this scenario

Suppose we are on the DevOps team at IRCTC, the railway ticketing company, working from New Delhi. Suresh Yadav leads the team, and we look after the tatkal booking API. Costs are counted in INR. In the tasks below we do real DevOps jobs on this project using what this lesson teaches. IRCTC is a real company, but this project, the people, servers, IP addresses and numbers are made up for practice.

0 / 12

Easy Check memory

Why: If RAM is full the server slows down or kills apps.

What to do: Show used and free memory in human-readable units.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Click Check answer.

Medium Prometheus scrape config

Why: Prometheus only knows what you tell it to scrape.

What to do: Write prometheus.yml with global scrape_interval 15s and one scrape job tatkal-booking with static_configs targets ["tatkal-booking:3000"].

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. Check the colons and spacing, then click Check answer.

Medium CPU and memory of pods

Why: Shows which pod is eating resources right now.

What to do: Show CPU and memory use of pods in irctc-prod.

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. Add names, files or paths at the end, then click Check answer.

Medium Disk usage alert

Why: A full disk stops databases and builds without warning.

What to do: Write a bash script: USAGE=$(df / --output=pcent | tail -1 | tr -dc '0-9'); if [ "$USAGE" -gt 80 ], echo "Disk at $USAGE%" and exit 2; close the if.

How:
  1. Start the script with #!/bin/bash.
  2. Write one step per line: variables, tests, loops.
  3. Close every if with fi and every loop with done.
  4. Click Check answer.

Medium Health-check script

Why: A tiny script in cron alerts you before customers notice.

What to do: Write a bash script: set URL="https://irctc.example.com/health"; if curl -fs "$URL" > /dev/null succeeds, echo "UP", else echo "DOWN" and exit 1.

How:
  1. Start the script with #!/bin/bash.
  2. Write one step per line: variables, tests, loops.
  3. Close every if with fi and every loop with done.
  4. Click Check answer.

Hard Prometheus alert rule

Why: Alerting on a sustained condition avoids paging for a blip.

What to do: Write a rules file: groups list with name irctc, rules list with alert InstanceDown, expr up == 0, for 5m, labels severity critical.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. Check the colons and spacing, then click Check answer.

Hard ServiceMonitor for the Prometheus Operator

Why: In K8s the operator discovers targets through ServiceMonitors.

What to do: Write a monitoring.coreos.com/v1 ServiceMonitor tatkal-booking selecting matchLabels app: tatkal-booking, endpoints with port http and interval 30s.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. Check the colons and spacing, then click Check answer.

Hard Name the metric

Why: DORA metrics show how healthy the delivery process is.

What to do: Which four-letter metric measures the average time to restore service after an incident?

How:
  1. Write down the facts or numbers the task gives you.
  2. Work it out step by step.
  3. Type only the final answer (one word or number) in the box.
  4. Click Check answer.

Hard Error budget in minutes

Why: An SLO turns into a concrete downtime budget the team can spend.

What to do: The SLO is 99.9% availability over a 30-day month. How many minutes of downtime are allowed? (30 days = 43200 minutes)

How:
  1. Write down the facts or numbers the task gives you.
  2. Work it out step by step.
  3. Type only the final answer (one word or number) in the box.
  4. Click Check answer.

Hard Compose: wait for a healthy database

Why: The app crashes if it starts before the database is ready.

What to do: Write compose.yaml: db (mysql:8.0) with a healthcheck whose test is ["CMD", "mysqladmin", "ping", "-h", "localhost"] and interval 10s; app (image irctc/tatkal-booking:1.4.3) that depends_on db with condition service_healthy.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. Check the colons and spacing, then click Check answer.

Hard Add a HEALTHCHECK

Why: Docker and orchestrators restart containers that stop answering.

What to do: Write a Dockerfile: FROM irctc/tatkal-booking:1.4.3, then a HEALTHCHECK every 30s with timeout 3s that runs curl -f http://localhost:3000/health || exit 1.

How:
  1. Start with FROM and the base image.
  2. Set WORKDIR, then COPY files and RUN install steps, one instruction per line.
  3. Add ENV, EXPOSE or USER lines if the task asks.
  4. End with CMD (or ENTRYPOINT) and click Check answer.

Hard Readiness and liveness probes

Why: Readiness stops traffic to a pod that is not ready; liveness restarts a stuck one.

What to do: Write a Pod tatkal-booking (container app, image irctc/tatkal-booking:1.4.3) with a readinessProbe httpGet /ready on port 3000 and a livenessProbe httpGet /health on port 3000 with initialDelaySeconds 10.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. Check the colons and spacing, then click Check answer.

Ravi Sir's Cards: 29 revision, interview and comparison cards for this chapter · मराठी cards