Skip to content

UnityInFlow/expense-tracker-observability

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Expense Tracker — Observability Demo

See how your Spring Boot app connects to Prometheus and Grafana. This is a bonus demo for the Expense Tracker workshop — showing DevOps engineers the bridge between the app they built and the monitoring they already know.

What's Inside

Component Port URL
Spring Boot App 8080 http://localhost:8080/swagger-ui.html
Actuator Metrics 8080 http://localhost:8080/actuator/prometheus
Prometheus 9090 http://localhost:9090
Grafana 3000 http://localhost:3000 (admin/admin)

Quick Start

1. Start Prometheus + Grafana:

docker compose up -d

2. Start the Spring Boot app:

cd app
./mvnw spring-boot:run

3. Open the dashboards:

  • Grafana: http://localhost:3000 (login: admin / admin)
  • The "Expense Tracker" dashboard is pre-configured

4. Generate some traffic:

Open Swagger UI at http://localhost:8080/swagger-ui.html and:

  • Add a few expenses (POST /expenses)
  • List them (GET /expenses)
  • Delete some (DELETE /expenses/{id})

Watch the Grafana dashboard update in real time!

What You'll See

Actuator Endpoints

Endpoint What it shows
/actuator/health App health status (UP/DOWN)
/actuator/info App info
/actuator/prometheus All metrics in Prometheus format
/actuator/metrics List of available metric names

Grafana Dashboard Panels

Panel What it shows
HTTP Request Rate Requests per second by endpoint
Response Time (p95) 95th percentile response time
Expenses Added Counter of POST operations
Expenses Deleted Counter of DELETE operations
JVM Heap Memory Memory usage over time
JVM Threads Number of live threads
GC Pause Time Garbage collection impact
CPU Usage Process CPU utilization
Uptime How long the app has been running

Custom Business Metrics

The app exposes custom Micrometer counters:

expenses_added_total    — number of expenses created
expenses_deleted_total  — number of expenses deleted

These are defined in ExpenseController.kt using Counter.builder().

How It Works

Browser/Swagger UI
       │
       ▼
Spring Boot App (:8080)
  ├── /expenses          — REST API
  └── /actuator/prometheus — metrics endpoint
       │
       ▼ (scrapes every 5s)
Prometheus (:9090)
       │
       ▼ (queries)
Grafana (:3000)
  └── Dashboard: Expense Tracker
  1. Spring Boot Actuator exposes metrics at /actuator/prometheus
  2. Micrometer collects JVM, HTTP, and custom metrics
  3. Prometheus scrapes the endpoint every 5 seconds
  4. Grafana queries Prometheus and visualizes the data

Key Files

File Purpose
app/pom.xml spring-boot-starter-actuator + micrometer-registry-prometheus
app/src/.../application.yaml Actuator endpoint exposure config
app/src/.../ExpenseController.kt Custom Micrometer counters
docker-compose.yml Prometheus + Grafana containers
prometheus/prometheus.yml Scrape config targeting localhost:8080
grafana/dashboards/expense-tracker.json Pre-built Grafana dashboard

Cleanup

docker compose down

Related

About

Expense Tracker — Spring Boot Actuator + Prometheus + Grafana. Bonus demo for DevOps workshops.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages