mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-02 00:40:10 +00:00
Fix count_by_severity_and_time_historical with clickhouse (#6046)
This commit is contained in:
parent
00e49d9383
commit
211bce6731
1 changed files with 8 additions and 2 deletions
|
|
@ -916,10 +916,16 @@ function alert_store:count_by_severity_and_time_historical()
|
|||
-- Preserve all the filters currently set
|
||||
local min_slot, max_slot, time_slot_width = self:_count_by_time_get_bounds()
|
||||
local where_clause = self:build_where_clause()
|
||||
local q
|
||||
|
||||
-- Group by according to the timeslot, that is, the alert timestamp MODULO the slot width
|
||||
local q = string.format("SELECT severity, (tstamp - tstamp %% %u) as slot, count(*) count FROM %s WHERE %s GROUP BY severity, slot ORDER BY severity, slot ASC",
|
||||
time_slot_width, self._table_name, where_clause)
|
||||
if(ntop.isClickHouseEnabled()) then
|
||||
q = string.format("SELECT severity, (toUnixTimestamp(tstamp) - toUnixTimestamp(tstamp) %% %u) as slot, count(*) count FROM %s WHERE %s GROUP BY severity, slot ORDER BY severity, slot ASC",
|
||||
time_slot_width, self._table_name, where_clause)
|
||||
else
|
||||
q = string.format("SELECT severity, (tstamp - tstamp %% %u) as slot, count(*) count FROM %s WHERE %s GROUP BY severity, slot ORDER BY severity, slot ASC",
|
||||
time_slot_width, self._table_name, where_clause)
|
||||
end
|
||||
|
||||
local q_res = interface.alert_store_query(q) or {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue