Skip to content

counter_series:sum_over

series:sum_over(duration)
Since: Dev Builds Only

The functionality described in this section requires a dev build of KumoMTA. You can obtain a dev build by following the instructions in the Installation section.

Returns the rolling total over the requested time span.

  • duration — span to sum over. Accepts an integer number of seconds, or a duration string such as "30s", "5m".

The duration is rounded up to a whole number of buckets, so a span shorter than bucket_size still includes the current bucket. The effective span is also capped at num_buckets * bucket_size; requesting a longer span is equivalent to calling sum.

Calling sum_over also rotates the ring buffer, so any buckets that have aged out since the last access are zeroed before the result is computed.

Example

local series = kumo.counter_series.define {
  name = 'deliveries.ok',
  num_buckets = 5,
  bucket_size = '1m',
}
print('last 2 minutes:', series:sum_over '2m')