From 6536ecb984f08dafd88b575eb12bfd37b2c38c8d Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Fri, 20 Jan 2017 13:27:50 -0800 Subject: [PATCH] journal probe: send records for every log message The previous logic concatenates log messages on initial startup, when the entire journal is read to process existing messages. But doing so might run into the payload size limit (8KB), and thus fail to create a record. Sending one record per log message will ensure that the payload size remains relatively small, almost always below the 8KB size limit. Signed-off-by: Patrick McCarty --- src/probes/journal.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/probes/journal.c b/src/probes/journal.c index d8246fc..139d85a 100644 --- a/src/probes/journal.c +++ b/src/probes/journal.c @@ -122,6 +122,16 @@ static int read_new_entries(sd_journal *journal) add_to_payload(data, length); + // For now, we send one record per log message, in case the + // there is a large backlog of messages and we exceed the + // payload size limit (8KB). And ignore errors, hoping that it's + // a transient problem. + + if (!send_data(error_class)) { + telem_log(LOG_ERR, "Failed to send data. Ignoring.\n"); + return num_entries; + } + num_entries++; } @@ -151,17 +161,11 @@ static bool process_existing_entries(sd_journal *journal) ret = read_new_entries(journal); if (ret < 0) { return false; - } - - if (!payload) { + } else if (ret == 0) { telem_log(LOG_DEBUG, "No existing entries found\n"); return true; } - if (!send_data(error_class)) { - return false; - } - return true; } @@ -278,10 +282,6 @@ static bool process_journal(void) } else if (r < 0) { return false; } - - if (!send_data(error_class)) { - return false; - } } } }