feat: add delta mode for counter metrics using ClickHouse lag()
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 1m17s
CI / docker (push) Successful in 1m12s
CI / deploy-feature (push) Has been skipped
CI / deploy (push) Successful in 42s

Counter metrics like chunks.exported.count are monotonically increasing.
Add mode=delta query parameter to the agent metrics API that computes
per-bucket deltas server-side using ClickHouse lag() window function:
max(value) per bucket, then greatest(0, current - previous) to get the
increase per period with counter-reset handling.

The chunks exported/dropped charts now show throughput per bucket
instead of the ever-increasing cumulative total.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-13 10:56:06 +02:00
parent ae908fb382
commit e57343e3df
5 changed files with 69 additions and 5 deletions

View File

@@ -11,4 +11,11 @@ public interface MetricsQueryStore {
Map<String, List<MetricTimeSeries.Bucket>> queryTimeSeries(
String instanceId, List<String> metricNames,
Instant from, Instant to, int buckets);
/** Counter mode: returns per-bucket deltas (max - previous max, floored at 0). */
default Map<String, List<MetricTimeSeries.Bucket>> queryTimeSeriesDelta(
String instanceId, List<String> metricNames,
Instant from, Instant to, int buckets) {
return queryTimeSeries(instanceId, metricNames, from, to, buckets);
}
}