🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101

Monitoring with Prometheus and Grafana

Add metrics to an app, collect them with Prometheus, build Grafana dashboards and alert when something breaks.

Advanced⏱ 10–14 hoursđŸĒœ 7 stepsPrometheusGrafanaDocker Compose

What you'll learn

  • ◆Metrics types (counter, gauge, histogram)
  • ◆PromQL queries
  • ◆Dashboards and alerting

What you'll build

  • ✓App exposes /metrics
  • ✓Request rate, error rate, latency (p95) dashboard
  • ✓Server CPU and memory via node exporter
  • ✓Alert when error rate > 5%

Step-by-step guide

  1. 1

    Instrument the app

    Use a Prometheus client library (prom-client for Node, Micrometer for Spring Boot, prometheus_client for Python).

  2. 2

    Key metrics

    http_requests_total{route,status} counter and http_request_duration_seconds histogram.

  3. 3

    Compose stack

    Services: app, prometheus (with prometheus.yml scrape config), grafana, node-exporter.

  4. 4

    PromQL

    Rate: sum(rate(http_requests_total[5m])); errors: share of status=~"5.."; p95: histogram_quantile(0.95, sum by (le) (rate(...[5m]))).

  5. 5

    Dashboard

    Grafana panels for the four golden signals; save the dashboard JSON in the repo.

  6. 6

    Alerts

    An alert rule for high error rate and for the app being down (up == 0).

  7. 7

    Break it

    Add a debug endpoint that returns errors and show the alert firing.

🚀 Make it stand out

  • +Logs with Loki
  • +Tracing with OpenTelemetry
  • +SLOs and error budgets