Fix top_local_network_id_historical with clickhouse (#6046)

This commit is contained in:
Alfredo Cardigliano 2021-11-05 16:21:51 +01:00
parent f22fb26f7f
commit b277d36ae7

View file

@ -92,8 +92,14 @@ function network_alert_store:top_local_network_id_historical()
-- Preserve all the filters currently set
local where_clause = self:build_where_clause()
local q = string.format("SELECT local_network_id, count(*) count, name FROM %s WHERE %s GROUP BY local_network_id ORDER BY count DESC LIMIT %u",
self._table_name, where_clause, self._top_limit)
local q
if ntop.isClickHouseEnabled() then
q = string.format("SELECT local_network_id, count(*) count, name FROM %s WHERE %s GROUP BY local_network_id, name ORDER BY count DESC LIMIT %u",
self._table_name, where_clause, self._top_limit)
else
q = string.format("SELECT local_network_id, count(*) count, name FROM %s WHERE %s GROUP BY local_network_id ORDER BY count DESC LIMIT %u",
self._table_name, where_clause, self._top_limit)
end
local q_res = interface.alert_store_query(q) or {}