What is the difference between a counter and a gauge? [Basic]
Answer
A counter represents a cumulative value that only increases except when the process restarts. A gauge represents a current value that can go up or down.
Technical explanation
Use rate() or increase() on counters to calculate activity over time.
Use gauges directly or with avg_over_time, max_over_time, or min_over_time depending on the question.
Using a gauge for request totals or a counter for queue depth creates misleading dashboards and alerts.
Hands-on example
Example: http_requests_total is a counter, so query rate(http_requests_total[5m]). queue_depth is a gauge, so query max_over_time(queue_depth[10m]) or avg(queue_depth) by (queue). Do not apply rate() to queue_depth unless it explicitly represents a cumulative total.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Observability interview questions
- What are the Prometheus metric types (counter, gauge, histogram, summary)? [Basic]
- What is a time series in Prometheus, and how is it identified (metric name plus labels)? [Basic]
- How does Prometheus collect metrics — what is the pull model and scraping? [Basic]
- What is a scrape target, and how does service discovery find them? [Basic]
- What is the difference between a symptom-based and a cause-based alert, and which is better? [Basic]
- What is the difference between an exporter and instrumenting your app directly? [Basic]
- Why are multi-window, multi-burn-rate alerts better than a single threshold? [Basic]
- What is the Pushgateway, and why is it discouraged for most cases? [Basic]