Count vs value metrics: which one to use
Short answer: use a count metric for things that happen, like signups, orders or errors. Use a value metric for measurements, like response time, queue length or MRR. The difference is how the numbers are combined: counts are added up over each hour or day, values are averaged.
Monitoring tools use other names for the same idea. Prometheus and StatsD call a count a counter and a value a gauge. The rule is the same everywhere: if adding two numbers together makes sense, it is a count.
Side by side
| Count | Value | |
|---|---|---|
| Answers | How many times did it happen? | How big was it? |
| Also called | Counter, event metric | Gauge, measurement |
| Per hour or day | Sum of the samples | Average of the samples |
| Usual sample | 1 per event (or a batch total) | The measured number |
| Examples | Signups, orders, page views, failed logins, deploys, cron runs | Response time, CPU or disk use, queue length, MRR, active users, temperature |
Why it matters: the same samples, two answers
Say three samples arrive within one hour: 200, 300 and 400. As a count, the hour shows 900. As a value, it shows 300. Neither is wrong; they answer different questions. Pick the wrong type and the chart is misleading:
- Response time as a count adds up the milliseconds, so the chart just rises and falls with traffic. A slow hour with few requests looks fast.
- Signups as a value averages the 1s you send, so every hour shows 1 no matter how many people signed up.
Sending each kind
Both use the same request. Only the number you send differs.
# Count: one request per signup curl "https://data.umlogger.com/api/m?key=pmk_SIGNUPS_KEY&value=1" # Value: the measurement itself curl "https://data.umlogger.com/api/m?key=pmk_RESPONSE_TIME_KEY&value=184"
A count doesn't have to be 1. If you batch events, send the total: a request with value=25 counts as 25 signups. That also keeps busy metrics under the limit of 120 requests per minute per key.
Common mistakes
- Sending a running total to a count. If your script reports "1,240 users so far" every hour, that is a value. As a count it gets added up again and grows without end. Send the change (new users this hour) to a count, or the total to a value.
- Averaging percentages from very different groups. A value metric weighs each sample the same. If one sample covers 10 requests and another 10,000, send the underlying counts instead and work out the rate from them.
- Expecting zero when nothing happens. No samples means no data, not zero. Turn on zero-fill in the chart settings if quiet hours should show as 0.
Alerts work differently for each
Umlogger's Value and Change alerts look at the average sample over a time window, so they fit value metrics: "average response time above 500 ms over the last hour". For a count metric, the most useful alert is Records, which fires when no data arrives in a window, for example no orders in 6 hours. More in how to get alerted when a number stops moving.
Chose the wrong one?
You can change a metric's type later. Umlogger stores every sample as it arrived, so nothing is lost: only the way the chart combines them changes.
Ready to send one? There are copy-paste examples for Python, Node.js, Go, PHP and shell scripts.