Monitoring Metrics - Counter (Increasing counter)
Table of Contents
About
A counter is a metrics type that increments its value generally by one starting from 0.
It is used to record occurrences of events like the number of page loaded or customer arrivals.
A counter will drop back to zero on service restart. Representing a counter without rate aggregation over some time window is rarely useful, as the representation is a function of both:
- the rapidity with which the counter is incremented
- and the longevity of the service.
Increasing counter starts at zero, increasing when an action occurs. This type of counter will probably have a maximum value. If this value is reached, the counter starts over at zero. This is the same as many counters in the world such as the mileage counter in a car.
Usage
Counter are used to measure the rate at which some event is occurring over a given time interval. (ie Performance - (Throughput|Bandwidth|Transfer rate|Frequency))
Example: in a queue, counters can measure things like the rate at which items are being inserted and removed.
Report
A counter reports:
- the number of observations,
- its current value
- the minimum and maximum values.
Example
Micrometer
Counter counter = Counter
.builder("counter")
.baseUnit("beans") // optional
.description("a description of what this counter does") // optional
.tags("region", "test") // optional
.register(registry);