Kubernetes and Cloud Native Associate (KCNA)Cloud Native ObservabilityMedium

A developer needs to add custom metrics to their Go application running in Kubernetes. These metrics should track specific business logic events, such as the number of successful user sign-ups or failed payment transactions. The target monitoring system is Prometheus. Which Prometheus client library feature should the developer use to expose these application-specific metrics?

  1. ACounter
  2. BGauge
  3. CHistogram
  4. DSummary
Show answer & explanation

Correct answer: A. Counter

A Counter is a cumulative metric that represents a single monotonically increasing number. It is ideal for tracking events that only ever increment, such as the number of successful sign-ups or failed transactions. Gauges measure current values, and Histograms/Summaries measure observed values within a sample, often for latency or size distributions.

Why the other options are wrong

  • B. Gauge represents a single numerical value that can arbitrarily go up and down (e.g., current CPU usage), not cumulative events.
  • C. Histogram samples observations and summarizes their distribution (e.g., request durations), not simple counts of events.
  • D. Summary also samples observations, providing quantiles over a sliding time window, similar to a Histogram but with different aggregation, not for simple event counts.

Prometheus Counter

A Prometheus metric type that represents a single, monotonically increasing cumulative value, which can only be incremented or reset to zero on restart.

  • Used for tracking counts of events (e.g., requests served, errors encountered).
  • Cannot decrease its value (except on restart).
  • Often combined with `rate()` or `irate()` functions in PromQL for per-second rates.

Memory trick: Count the events, Gauge the current, Histogram the distribution.

More Cloud Native Observability questions