diff --git a/scripts/lua/modules/alert_store/network_alert_store.lua b/scripts/lua/modules/alert_store/network_alert_store.lua index d458934306..4466c0205a 100644 --- a/scripts/lua/modules/alert_store/network_alert_store.lua +++ b/scripts/lua/modules/alert_store/network_alert_store.lua @@ -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 {}