From 0a73f356e6af18d1f78534667a4bd298bb08ce19 Mon Sep 17 00:00:00 2001 From: Dmitriy Alekseev <1865999+dragoangel@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:16:44 +0200 Subject: round time_diff to seconds on interval check, improve log message readability --- src/plugins/lua/elastic.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/lua/elastic.lua b/src/plugins/lua/elastic.lua index 45c5c2edf..18c29711f 100644 --- a/src/plugins/lua/elastic.lua +++ b/src/plugins/lua/elastic.lua @@ -658,9 +658,10 @@ local function periodic_send_data(cfg, ev_base) local first_row = buffer['logs']:get(1) if first_row then local time_diff = now - first_row['@timestamp'] - if time_diff > settings.limits.max_interval * 1000 then - rspamd_logger.infox(rspamd_config, 'flushing buffer by reaching max interval, diff: %s, current time: %s, log timestamp: %s', - time_diff, now, first_row['@timestamp']) + local time_diff_sec = lua_util.round((time_diff / 1000), 1) + if time_diff_sec > settings.limits.max_interval then + rspamd_logger.infox(rspamd_config, 'flushing buffer for %s by reaching max interval, oldest log in buffer written %s sec ago', + time_diff_sec, first_row['@timestamp']) flush_needed = true else local size = buffer['logs']:size() -- cgit v1.2.3