From 9197239d3462cc6d599b4b5e40884c058cfd4107 Mon Sep 17 00:00:00 2001 From: Olli Jarva Date: Tue, 5 Feb 2019 10:32:25 +0200 Subject: [PATCH] stats: reduce logging output Reduce amount of logging output for normal operations, as it does not add much value to know immediately about recently sent messages, which in busy machines produce a significant amount of logging. --- journalpump/journalpump.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/journalpump/journalpump.py b/journalpump/journalpump.py index 31f467f..670e9fc 100644 --- a/journalpump/journalpump.py +++ b/journalpump/journalpump.py @@ -534,6 +534,9 @@ def __init__(self, *, name, config, field_filters, geoip, stats, self.read_lines = 0 self._last_sent_read_lines = 0 self._last_sent_read_bytes = 0 + self._sent_bytes_diff = 0 + self._sent_lines_diff = 0 + self.last_stats_print_time = time.monotonic() self.geoip = geoip self.config = config self.field_filters = field_filters @@ -674,10 +677,14 @@ def inc_line_stats(self, *, journal_lines, journal_bytes): self.stats.gauge("journal.read_lines", value=self.read_lines, tags=tags) self.stats.gauge("journal.read_bytes", value=self.read_bytes, tags=tags) self.last_stats_send_time = now - lines_diff = self.read_lines - self._last_sent_read_lines - bytes_diff = self.read_bytes - self._last_sent_read_bytes - if lines_diff or bytes_diff: - self.log.info("Processed %r journal lines (%r bytes)", lines_diff, bytes_diff) + self._sent_lines_diff += self.read_lines - self._last_sent_read_lines + self._sent_bytes_diff += self.read_bytes - self._last_sent_read_bytes + if now - self.last_stats_print_time > 120: + self.log.info("Processed %r journal lines (%r bytes)", self._sent_lines_diff, self._sent_bytes_diff) + self._sent_lines_diff = 0 + self._sent_bytes_diff = 0 + self.last_stats_print_time = now + self._last_sent_read_lines = self.read_lines self._last_sent_read_bytes = self.read_bytes