Reworked clickhouse retention

This commit is contained in:
Luca Deri 2023-05-31 11:39:05 +02:00
parent fa32379501
commit a4f731d61e
3 changed files with 32 additions and 3 deletions

View file

@ -10,6 +10,7 @@ local DEFAULT_DATA_RETENTION_DAYS = 30
local DEFAULT_AGGREGATED_FLOWS_DATA_RETENTION_DAYS = 60
local DEFAULT_DATA_RETENTION_DAYS_KEY = "ntopng.prefs.data_retention_days"
local FLOWS_AND_ALERTS_DATA_RETENTION_DAYS_KEY = "ntopng.prefs.flows_and_alerts_data_retention_days"
local AGGREGATED_FLOWS_DATA_RETENTION_DAYS_KEY = "ntopng.prefs.aggregated_flows_data_retention_days"
local TS_AND_STATS_DATA_RETENTION_DAYS_KEY = "ntopng.prefs.ts_and_stats_data_retention_days"
local data_retention_utils = {}
@ -36,6 +37,14 @@ end
-- ########################################################
function data_retention_utils.getAggregatedFlowsRetentionDays()
local data_retention = ntop.getCache(AGGREGATED_FLOWS_DATA_RETENTION_DAYS_KEY)
-- aggregated data is at least one day more that non-aggregated data
return tonumber(data_retention) or (data_retention_utils.getDefaultRetention() + 1)
end
-- ########################################################
function data_retention_utils.getTSAndStatsDataRetentionDays()
local data_retention = ntop.getCache(TS_AND_STATS_DATA_RETENTION_DAYS_KEY) or ntop.getCache(DEFAULT_DATA_RETENTION_DAYS_KEY)