mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
Fix InfluxDB charts statistics
This commit is contained in:
parent
1baa2ae393
commit
4cafac6a81
3 changed files with 67 additions and 62 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue