Interview Observability

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.

Preparing for an interview?

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

← All Observability questions