mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-10 00:42:14 +00:00
Implement queryLastValues for clickhouse ts
This commit is contained in:
parent
8e9128e9f9
commit
fc5c7a0dfd
1 changed files with 23 additions and 0 deletions
|
|
@ -652,6 +652,29 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
--! @brief Return the last N non-NaN values for each metric in the time range.
|
||||
--! Note: values are already normalised by driver:query()
|
||||
function driver:queryLastValues(options)
|
||||
local last_values = {}
|
||||
local rsp = self:timeseries_query(options)
|
||||
|
||||
for _, data in pairs(rsp.series or {}) do
|
||||
local values = {}
|
||||
for i = (#data.data), 1, -1 do
|
||||
if #values == options.num_points then break end
|
||||
-- nan check
|
||||
if data.data[i] == data.data[i] then
|
||||
values[#values + 1] = data.data[i]
|
||||
end
|
||||
end
|
||||
last_values[data.id] = values
|
||||
end
|
||||
|
||||
return last_values
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
--! @brief Flush the in-memory buffer to ClickHouse.
|
||||
--! Called periodically by the export script.
|
||||
function driver:export()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue