We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
This idea carries a full system design question on its own. Each walks through the full answer.
System Design Masterclass · Observability Monitoring
Free preview: the first 2 parts of this 7-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Observability Monitoring
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
The CEO walks over and asks: "How many orders did we process today?" If your answer involves SSHing into a server and running grep "order.completed" app.log | wc -l, you're doing it wrong.
A counter is the simplest and most useful metric type. It starts at zero and only goes up. Every time an event happens, a request arrives, an error occurs, a user signs up, you increment the counter. At any point, you can look at the counter's value and know exactly how many times that event has happened since the process started.
More importantly, you can calculate the rate, how fast is the counter increasing? "We processed 12,400 orders today" is useful. "We're processing 300 orders per minute, up from 200 per minute last Tuesday" is actionable. Counters give you both.
A counter has three rules:
| Time | Counter Value | Rate (per minute) |
|---|---|---|
| 10:00 | 1,000 | . |
| 10:01 | 1,045 | 45/min |
| 10:02 | 1,112 | 67/min |
| 10:03 | 1,150 | 38/min |
In , you'd use rate(http_requests_total[5m]) to get the per-second request rate averaged over the last 5 minutes. The rate() function handles counter resets (when a process restarts and the counter goes back to zero) automatically.
Common counters in production:
http_requests_total, total requests, labeled by method, path, status codehttp_errors_total, total error responsesorders_completed_total, business event countbytes_transferred_total, network db_queries_total, database call countThe key insight: you almost never look at the raw counter value. You always look at the rate. "We have served 47 million requests" is trivia. "We're serving 3,200 requests per second" is operational data.