Fix InfluxDB charts statistics

This commit is contained in:
emanuele-f 2018-07-20 14:18:38 +02:00
parent 1baa2ae393
commit 4cafac6a81
3 changed files with 67 additions and 62 deletions

View file

@ -229,39 +229,6 @@ end
-- ##############################################
local function calcStats(total_serie, step, tdiff)
local total = 0
local min_val, max_val
local min_val_pt, max_val_pt
for idx, val in pairs(total_serie) do
-- integrate
total = total + val * step
if (min_val_pt == nil) or (val < min_val) then
min_val = val
min_val_pt = idx - 1
end
if (max_val_pt == nil) or (val > max_val) then
max_val = val
max_val_pt = idx - 1
end
end
local avg = total / tdiff
return {
total = total,
average = avg,
min_val = min_val,
max_val = max_val,
min_val_idx = min_val_pt,
max_val_idx = max_val_pt,
}
end
-- ##############################################
local function sampleSeries(schema, cur_points, step, max_points, series)
local sampled_dp = math.ceil(cur_points / max_points)
local count = nil
@ -376,8 +343,7 @@ function driver:query(schema, tstart, tend, tags, options)
local stats = nil
if options.calculate_stats then
stats = calcStats(total_serie, fstep, tend - tstart)
stats["95th_percentile"] = ts_common.ninetififthPercentile(total_serie)
stats = ts_common.calculateStatistics(total_serie, fstep, tend - tstart)
end
return {
@ -547,8 +513,7 @@ function driver:topk(schema, tags, tstart, tend, options, top_tags)
total_serie = total_serie[1].data
if options.calculate_stats then
stats = calcStats(total_serie, step, tend - tstart)
stats["95th_percentile"] = ts_common.ninetififthPercentile(total_serie)
stats = ts_common.calculateStatistics(total_serie, step, tend - tstart)
end
return {