From 322c9e68667d2f9c3dd97c2d13cf745bea7d963c Mon Sep 17 00:00:00 2001 From: Christian Becker Date: Tue, 1 Sep 2020 12:31:12 +0200 Subject: [PATCH] add partial metadata to journald logs add all partial metadata available to journald logs to allow easier reassembly of partial messages in downstream logging systems fixes #41403 Signed-off-by: Christian Becker --- daemon/logger/journald/journald.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/daemon/logger/journald/journald.go b/daemon/logger/journald/journald.go index c3a2129341..382c552e55 100644 --- a/daemon/logger/journald/journald.go +++ b/daemon/logger/journald/journald.go @@ -6,6 +6,7 @@ package journald // import "github.com/docker/docker/daemon/logger/journald" import ( "fmt" + "strconv" "sync" "unicode" @@ -105,8 +106,13 @@ func (s *journald) Log(msg *logger.Message) error { for k, v := range s.vars { vars[k] = v } - if msg.PLogMetaData != nil && !msg.PLogMetaData.Last { - vars["CONTAINER_PARTIAL_MESSAGE"] = "true" + if msg.PLogMetaData != nil { + vars["CONTAINER_PARTIAL_ID"] = msg.PLogMetaData.ID + vars["CONTAINER_PARTIAL_ORDINAL"] = strconv.Itoa(msg.PLogMetaData.Ordinal) + vars["CONTAINER_PARTIAL_LAST"] = strconv.FormatBool(msg.PLogMetaData.Last) + if !msg.PLogMetaData.Last { + vars["CONTAINER_PARTIAL_MESSAGE"] = "true" + } } line := string(msg.Line)