Service metrics
Numbers that describe system health, such as error rate and latency.
Service metrics track rates, errors and durations over time. The RED and USE methods give simple starting sets. They are cheap to store and the basis for dashboards and alerts.
Why it matters for a product engineer
Service metrics are numbers over time: how many requests, how many fail, how long they take, how busy each resource is. They are cheap to collect and store, so they are the basis for dashboards and alerts. A small, standard set of metrics for every service means that anyone on the team can read any service’s health. Product engineers who instrument their own code know which numbers show what users feel.
How to do it
- For each service, record request rate, error rate and the distribution of latency, not only the average.
- For each resource, such as CPU, memory, disks, connection pools and queues, record how busy it is and how much work is waiting.
- Measure the latency of successful and failed requests separately.
- Use the same metric names and labels in every service.
- Keep labels with many possible values, such as user ids, out of metrics. Put them in logs or traces.
Common mistakes
- Only averages, which hide the slow requests that users notice.
- Many metrics nobody reads, and none for errors.
- Fast errors that make average latency look better.
- A user id as a metric label, which multiplies the storage cost.
Example
Google’s SRE book names four golden signals for a user-facing system: latency, traffic, errors and saturation. Two shorter checklists are common. Brendan Gregg published the USE method in 2012: for every resource, check utilization, saturation and errors. Tom Wilkie created the RED method in 2015, for microservices: for every service, measure rate, errors and duration. Many teams use RED for services and USE for the machines under them.
Two starting sets of service metrics
| RED | USE | |
|---|---|---|
| Created by | Tom Wilkie, 2015 | Brendan Gregg, 2012 |
| For each | Service | Resource: CPU, disk, network |
| Measures | Rate, errors, duration | Utilization, saturation, errors |
| Shows | What requests experience | Where the bottleneck is |
Three numbers per service and three per resource are enough to start. Each set answers a different question.
ReportedGrafana Labs blog, 2018; Brendan Gregg, The USE method
Sources: Monitoring distributed systems (Site Reliability Engineering, chapter 6, Google) ↗ · The RED method: how to instrument your services (Grafana Labs) ↗ · The USE method (Brendan Gregg) ↗
Resources
1- bookStart here
Monitoring distributed systems (Site Reliability Engineering, chapter 6) ↗
Google SRE · 20 minThe four golden signals and the case for alerting on symptoms users feel rather than on every cause.
Tools
1- ToolOpen source
Prometheus
Open-source metrics database and alerting, the common default for service metrics.