Course contentsShow
← System Design
Lesson 1174 of 1,91930. Observability: MetricsFree lesson

Counter Metrics

Understand counters as monotonically increasing values that track cumulative events like requests or errors.

Counter Metrics

What you'll learn: How counters track cumulative events as always-increasing values in distributed systems.

What is a Counter?

A counter is a metric type that represents a monotonically increasing value—it only goes up (or resets to zero). Counters track cumulative totals of discrete events over time, like the total number of HTTP requests received, errors encountered, or bytes transferred since your service started.

Think of a counter like an odometer in a car: it always increases as you drive more miles and never decreases (unless the car is replaced and starts over). You wouldn't use an odometer to tell your current speed—just the total distance traveled.

Why Counters Matter

Counters are ideal for tracking:

  • Total requests served by an API endpoint
  • Total errors encountered across all services
  • Total messages processed from a queue
  • Total database queries executed

The power of counters comes from rate calculation. While the raw counter value tells you cumulative totals, you typically care about the rate of change—requests per second, errors per minute. Monitoring systems calculate these rates by observing how quickly the counter increases over time windows.

Key Characteristics

Counters have two essential properties:

  1. Monotonic increase: They never decrease during normal operation
  2. Reset behavior: They start at zero when a service restarts

This reset behavior is crucial for monitoring systems to handle correctly. A sudden drop from 1,000,000 to 0 doesn't mean negative events—it means the service restarted.

Key Takeaway: Counters are monotonically increasing metrics perfect for tracking cumulative events; derive rates from them to measure throughput and error frequency over time.