# Metrics, Dashboards and Alerting

> Measure rates, errors and latency with Prometheus-style metrics, build dashboards and alert on user-visible symptoms. Free notes, key concepts, resources and a...

Canonical: https://www.internhack.in/roadmaps/tracks/backend/metrics-alerting
Last updated: 2026-11-28

Measure rates, errors and latency with Prometheus-style metrics, build dashboards and alert on user-visible symptoms.

Intermediate · about 5 hours · difficulty 3/5

Learn first: [Structured Logging](https://www.internhack.in/roadmaps/tracks/backend/structured-logging)

Logs tell you what happened to one request; **metrics** tell you how the whole system is behaving right now. They are cheap numeric time series you can graph and alert on.

### Metric types

- **Counter**: only goes up (`http_requests_total`). You graph its rate.
- **Gauge**: goes up and down (`queue_depth`, `db_pool_in_use`).
- **Histogram**: buckets of observed values (`http_request_duration_seconds`) so you can compute percentiles.

Add **labels** (route, method, status code) but keep them low-cardinality; a label per user id can take down your metrics system.

### What to measure

- **RED** for services: **R**ate, **E**rrors, **D**uration of requests.
- **USE** for resources: **U**tilization, **S**aturation, **E**rrors of CPU, memory, disks, pools.
- Google's **four golden signals**: latency, traffic, errors, saturation.
- Business metrics too: signups, checkouts, failed payments.

### Percentiles, not averages

An average latency of 100 ms can hide a p99 of 5 seconds that frustrates your best customers. Watch **p50, p95 and p99**.

### Tooling

**Prometheus** scrapes a `/metrics` endpoint from each instance and stores time series; **Grafana** builds dashboards. Hosted options include Grafana Cloud, Datadog and CloudWatch. OpenTelemetry can export metrics to any of them.

### Alerting well

- Alert on **symptoms users feel** (error rate above 2 percent, p99 above 1 s) rather than every cause (CPU at 80 percent).
- Define **SLOs** (for example 99.9 percent of requests succeed) and alert on error-budget burn rate.
- Every alert should be actionable and link to a runbook; noisy alerts get ignored.

You are ready to move on when your service exposes RED metrics, a Grafana dashboard shows p95 latency per route, and one symptom-based alert fires in a test.

## Key concepts

- **Counters, gauges and histograms**
- **Labels and cardinality**
- **RED and USE methods**
- **Percentile latency**
- **Prometheus and Grafana**
- **SLIs, SLOs and error budgets**
- **Symptom-based alerting and runbooks**

## Mini project

Instrument your API with request count and latency histograms, run Prometheus and Grafana with Docker Compose, build a RED dashboard and configure an alert for a high error rate.

## Check yourself

Why is alerting on high CPU usually worse than alerting on elevated error rate or latency?

## Free resources

- [Prometheus: Overview](https://prometheus.io/docs/introduction/overview/) (Prometheus)
- [SRE Book: Monitoring Distributed Systems](https://sre.google/sre-book/monitoring-distributed-systems/) (Google)
- [Grafana documentation](https://grafana.com/docs/grafana/latest/) (Grafana Labs)

Previous: [Structured Logging](https://www.internhack.in/roadmaps/tracks/backend/structured-logging) · Next: [Distributed Tracing with OpenTelemetry](https://www.internhack.in/roadmaps/tracks/backend/distributed-tracing-otel)

## More in Observability and Performance

- [Structured Logging](https://www.internhack.in/roadmaps/tracks/backend/structured-logging)
- [Metrics, Dashboards and Alerting](https://www.internhack.in/roadmaps/tracks/backend/metrics-alerting)
- [Distributed Tracing with OpenTelemetry](https://www.internhack.in/roadmaps/tracks/backend/distributed-tracing-otel)
- [Performance Profiling and Load Testing](https://www.internhack.in/roadmaps/tracks/backend/performance-profiling)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Backend Developer Roadmap](https://www.internhack.in/roadmaps/tracks/backend)
