Counter functions :: Kloudfuse Docs

Counter functions

Counter functions read monotonically increasing metrics — request totals, bytes sent — and turn raw counts into rates and increases while handling counter resets.

increase

Computes how much a counter grew over the range window — rate multiplied by the window length. Human-friendly for questions like "how many requests in the last hour".

Syntax

increase(<counter metric>[<range>])

Parameters

Parameter Required Description
<range> Required The trailing window to compute over, such as [5m].

Example

Count Kafka batches the Kloudfuse ingester consumed in the last hour.

sum(increase(ingester_kafka_batch_length_count[1h]))
Value
209,835,585.76

Expected output

The result is extrapolated from samples, so it can be non-integer even for integer counters.

irate

Computes the per-second rate using only the last two samples in the range window. irate reacts instantly to change, at the cost of volatility — suited to zoomed-in debugging graphs, not alerts.

Syntax

irate(<counter metric>[<range>])

Parameters

Parameter Required Description
<range> Required The trailing window to compute over, such as [5m].

Example

See the instantaneous Kafka batch consumption rate of the ingester.

sum(irate(ingester_kafka_batch_length_count[5m]))
Value
492,814.12

Expected output

Alerts on irate flap; prefer rate for anything automated.

rate

Computes the per-second average rate of increase of a counter over the range window, handling counter resets. This is the default way to chart any _total metric and the basis of most alerts.

Syntax

rate(<counter metric>[<range>])

Parameters

Parameter Required Description
<range> Required The trailing window to compute over, such as [5m].

Example

Measure how fast the Kloudfuse ingester consumes Kafka batches.

sum(rate(ingester_kafka_batch_length_count[5m]))
Value
208,927.21

Expected output

Use a range of at least 2–4× the scrape interval; shorter windows see too few samples.
For gauges, use delta or derivrate assumes counter semantics.

resets

Counts how many times a counter reset (dropped to a lower value) within the range window. Resets usually mean process restarts — a cheap restart detector from any counter you already collect.

Syntax

resets(<counter metric>[<range>])

Parameters

Parameter Required Description
<range> Required The trailing window to compute over, such as [5m].

Example

Check whether the ingester’s Kafka counter reset in the last hour — zero means no restarts.

max(resets(ingester_kafka_batch_length_count[1h]))
Value
2

Expected output

Any decrease counts as a reset; gauges therefore produce meaningless results.