From f25e003130364433804b3129fd31323a0a7a20e4 Mon Sep 17 00:00:00 2001 From: Mark Reibert Date: Thu, 9 Jan 2020 13:35:10 -0700 Subject: [PATCH] Fix percentile() function, closes #862 Like the other aggregation functions, the datapoints need to be sorted in time before calling groupBy_perf(). --- src/datasource-zabbix/dataProcessor.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/datasource-zabbix/dataProcessor.js b/src/datasource-zabbix/dataProcessor.js index e69ceda68..eb5d1a1bf 100644 --- a/src/datasource-zabbix/dataProcessor.js +++ b/src/datasource-zabbix/dataProcessor.js @@ -121,9 +121,11 @@ function aggregateWrapper(groupByCallback, interval, datapoints) { } function percentile(interval, n, datapoints) { - var flattenedPoints = ts.flattenDatapoints(datapoints); - var groupByCallback = _.partial(PERCENTILE, n); - return groupBy(flattenedPoints, interval, groupByCallback); + const flattenedPoints = ts.flattenDatapoints(datapoints); + // groupBy_perf works with sorted series only + const sortedPoints = ts.sortByTime(flattenedPoints); + let groupByCallback = _.partial(PERCENTILE, n); + return groupBy(sortedPoints, interval, groupByCallback); } function timeShift(interval, range) {