mirror of
https://github.com/grafana/grafana.git
synced 2025-01-01 11:47:05 -06:00
Add delta window function to postgres query builder
Unlike the increase function delta doesn't check for resets and can go negative. This is similar to the prometheus delta function.
This commit is contained in:
parent
5c1615292a
commit
f608340c35
@ -184,6 +184,11 @@ export default class PostgresQuery {
|
||||
switch (windows.type) {
|
||||
case 'window':
|
||||
switch (windows.params[0]) {
|
||||
case 'delta':
|
||||
curr = query;
|
||||
prev = 'lag(' + curr + ') OVER (' + over + ')';
|
||||
query = curr + ' - ' + prev;
|
||||
break;
|
||||
case 'increase':
|
||||
curr = query;
|
||||
prev = 'lag(' + curr + ') OVER (' + over + ')';
|
||||
|
@ -158,6 +158,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
|
||||
text: 'Window Functions',
|
||||
value: 'window',
|
||||
submenu: [
|
||||
{ text: 'Delta', value: 'delta' },
|
||||
{ text: 'Increase', value: 'increase' },
|
||||
{ text: 'Rate', value: 'rate' },
|
||||
{ text: 'Sum', value: 'sum' },
|
||||
|
@ -107,7 +107,7 @@ register({
|
||||
{
|
||||
name: 'function',
|
||||
type: 'string',
|
||||
options: ['increase', 'rate', 'sum'],
|
||||
options: ['delta', 'increase', 'rate', 'sum'],
|
||||
},
|
||||
],
|
||||
defaultParams: ['increase'],
|
||||
|
Loading…
Reference in New Issue
Block a user