feat: add delta mode for counter metrics using ClickHouse lag()
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user