Skip to content

Module 2: Observability & Actuator (The Health Monitor)

📚 Module 2: Observability & Actuator

Focus: Moving from “Is it running?” to “How is it feeling?”

In production, you can’t just look at your laptop to see if the app is working. You need Observability. We use Spring Boot Actuator to let the app “Talk” to us about its health.


🏗️ Step 1: The “Black Box” Problem

Imagine you have a robot working in a dangerous cave.

  • You are sitting outside the cave.
  • The Problem: You don’t know if the robot is out of battery, stuck, or just taking a break. You need it to send you Signals.

🏗️ Step 2: Actuator (The “Heart Monitor”)

Spring Boot Actuator adds a set of special “Signals” (Endpoints) to your app that tell you exactly what is happening inside.

🧩 The Analogy: The Fitness Tracker

  • Health Check: Is the heart still beating? (Status: UP).
  • Metrics: What is the heart rate? (CPU usage, Memory).
  • Log View: What is the robot thinking right now? (Logs).

In Code: Just add this to your pom.xml:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

🏗️ Step 3: Prometheus & Grafana (The “Dashboard”)

Actuator gives you the raw data. Prometheus collects that data, and Grafana turns it into beautiful charts.

🧩 The Analogy: The Doctor’s Screen

  • Actuator: The sensors attached to the patient.
  • Prometheus: The machine that records the heartbeats every second.
  • Grafana: The screen that shows the doctor a pretty green line of the heart rate.

🥅 Module 2 Review

  1. Observability: The ability to understand the internal state of your app from the outside.
  2. Actuator: The built-in Spring tool for exposing health and metrics.
  3. Metrics: Numerical data (like 80% CPU usage).
  4. Health Check: A simple “Yes/No” to see if the app is alive.