From 2b932492c26bd072d8e9361e57a0384ff29fe68e Mon Sep 17 00:00:00 2001 From: oliverpool Date: Thu, 12 Jan 2017 16:19:18 +0100 Subject: [PATCH 1/3] Add a `diff` aggregate `diff = current - first` (when available) --- public/app/core/time_series2.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/app/core/time_series2.ts b/public/app/core/time_series2.ts index 4503be68710..4563a09cbca 100644 --- a/public/app/core/time_series2.ts +++ b/public/app/core/time_series2.ts @@ -104,6 +104,7 @@ export default class TimeSeries { this.stats.current = null; this.stats.first = null; this.stats.delta = 0; + this.stats.diff = null; this.stats.range = null; this.stats.timeStep = Number.MAX_VALUE; this.allIsNull = true; @@ -193,6 +194,9 @@ export default class TimeSeries { if (this.stats.max !== null && this.stats.min !== null) { this.stats.range = this.stats.max - this.stats.min; } + if (this.stats.current !== null && this.stats.first !== null) { + this.stats.diff = this.stats.current - this.stats.first; + } this.stats.count = result.length; return result; From 92a0b402c53585f4de829273a793dfcd921d92e9 Mon Sep 17 00:00:00 2001 From: oliverpool Date: Thu, 12 Jan 2017 16:22:41 +0100 Subject: [PATCH 2/3] Add `diff` documentation --- docs/sources/reference/singlestat.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sources/reference/singlestat.md b/docs/sources/reference/singlestat.md index f22d496323a..9f2edb7df05 100644 --- a/docs/sources/reference/singlestat.md +++ b/docs/sources/reference/singlestat.md @@ -31,6 +31,7 @@ The singlestat panel has a normal query editor to allow you define your exact me * `total` - The sum of all the non-null values in the series * `first` - The first value in the series * `delta` - The total incremental increase (of a counter) in the series. An attempt is made to account for counter resets, but this will only be accurate for single instance metrics. Used to show total counter increase in time series. + * `diff` - The difference betwen 'current' (last value) and 'first'. * `range` - The difference between 'min' and 'max'. Useful the show the range of change for a gauge. 4. `Postfixes`: The Postfix fields let you define a custom label and font-size (as a %) to appear *after* the value 5. `Units`: Units are appended to the the Singlestat within the panel, and will respect the color and threshold settings for the value. From 80c67267e81df7500b81533acac98a1e9635cc87 Mon Sep 17 00:00:00 2001 From: oliverpool Date: Thu, 12 Jan 2017 16:23:57 +0100 Subject: [PATCH 3/3] Add the `diff` option on the singlestat panel --- public/app/plugins/panel/singlestat/module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index 1da40ddd25e..23283e98591 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -21,7 +21,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { invalidGaugeRange: boolean; panel: any; events: any; - valueNameOptions: any[] = ['min','max','avg', 'current', 'total', 'name', 'first', 'delta', 'range']; + valueNameOptions: any[] = ['min','max','avg', 'current', 'total', 'name', 'first', 'delta', 'diff', 'range']; // Set and populate defaults panelDefaults = {