diff --git a/public/app/plugins/datasource/postgres/postgres_query.ts b/public/app/plugins/datasource/postgres/postgres_query.ts index 89518bb15e0..e315f1fecd2 100644 --- a/public/app/plugins/datasource/postgres/postgres_query.ts +++ b/public/app/plugins/datasource/postgres/postgres_query.ts @@ -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 + ')'; diff --git a/public/app/plugins/datasource/postgres/query_ctrl.ts b/public/app/plugins/datasource/postgres/query_ctrl.ts index 9343a260a9e..aa66a1594cb 100644 --- a/public/app/plugins/datasource/postgres/query_ctrl.ts +++ b/public/app/plugins/datasource/postgres/query_ctrl.ts @@ -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' }, diff --git a/public/app/plugins/datasource/postgres/sql_part.ts b/public/app/plugins/datasource/postgres/sql_part.ts index 695060f6366..f8caaf0e39e 100644 --- a/public/app/plugins/datasource/postgres/sql_part.ts +++ b/public/app/plugins/datasource/postgres/sql_part.ts @@ -107,7 +107,7 @@ register({ { name: 'function', type: 'string', - options: ['increase', 'rate', 'sum'], + options: ['delta', 'increase', 'rate', 'sum'], }, ], defaultParams: ['increase'],