Blame SOURCES/002-redis-pass-correct-timespec.patch

2ae673
diff --git a/src/datasources/redis/datasource.ts b/src/datasources/redis/datasource.ts
2ae673
index 5980ffa..1d108a9 100644
2ae673
--- a/src/datasources/redis/datasource.ts
2ae673
+++ b/src/datasources/redis/datasource.ts
2ae673
@@ -170,15 +170,14 @@ export class PCPRedisDatasource {
2ae673
             }
2ae673
         }
2ae673
 
2ae673
-        const sampleIntervalSec = 60; // guessed sample interval
2ae673
+        const interval = query.intervalMs / 1000; // seconds
2ae673
         // request a bigger time frame to fill the chart (otherwise left and right border of chart is empty)
2ae673
         // because of the rate conversation of counters first datapoint is "lost" -> expand timeframe at the beginning
2ae673
-        const start = Math.round(query.range.from.valueOf() / 1000) - 2 * sampleIntervalSec;
2ae673
-        const finish = Math.round(query.range.to.valueOf() / 1000) + sampleIntervalSec;
2ae673
-        const samples = Math.round((query.range.to.valueOf() - query.range.from.valueOf()) / query.intervalMs);
2ae673
-        // const interval = query.interval;
2ae673
+        const additionalTimeRange = Math.max(interval, 60); // 60s is the default sample interval of pmlogger
2ae673
+        const start = Math.floor(query.range.from.valueOf() / 1000 - 2 * additionalTimeRange); // seconds
2ae673
+        const finish = Math.ceil(query.range.to.valueOf() / 1000 + additionalTimeRange); // seconds
2ae673
 
2ae673
-        const instances = await this.pmSeriesSrv.getValues(seriesList, { start, finish, samples });
2ae673
+        const instances = await this.pmSeriesSrv.getValues(seriesList, { start, finish, interval });
2ae673
         const descriptions = await this.pmSeriesSrv.getDescriptions(seriesList);
2ae673
         const metricNames = await this.pmSeriesSrv.getMetricNames(seriesList);
2ae673
         const instanceValuesGroupedBySeries = _.groupBy(instances, "series");
2ae673
-- 
2ae673
2.21.1
2ae673