From 1ddc479e4bc4307b3ef998d3d539fa5d92c61bec Mon Sep 17 00:00:00 2001 From: rasmus Date: Sun, 6 Nov 2022 15:57:18 +0200 Subject: [PATCH] log errors in lines, and ignore empty lines --- cmd/submit.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/submit.go b/cmd/submit.go index 69aa959..fdcedf3 100644 --- a/cmd/submit.go +++ b/cmd/submit.go @@ -73,7 +73,7 @@ func (s *submitter) shipFile(ctx context.Context, name string, deleteAfterRead b } promFileErr.WithLabelValues(baseName).Add(1) - s.l.Error("shipping file", zap.String("filename", baseName), zap.Error(err)) + s.l.Error("shipping file", zap.String("filename", name), zap.Error(err)) return false, nil // nil since we want to loop and keep retrying indefinitely }) } @@ -135,6 +135,10 @@ func (s *submitter) shipFileRoutine(ctx context.Context, name string, sendQueue } } + if line.String == "" { + continue + } + var collectTime time.Time var stdErr, format, log string @@ -142,6 +146,7 @@ func (s *submitter) shipFileRoutine(ctx context.Context, name string, sendQueue if len(split) != 4 { log = line.String promLineParsingErr.WithLabelValues(baseName).Add(1) + s.l.Error("parsing line", zap.Error(fmt.Errorf("expected at least 3 spaces in container log")), zap.Int("got", len(split)-1), zap.String("file", name)) } else { stdErr, format, log = split[1], split[2], split[3] @@ -149,6 +154,7 @@ func (s *submitter) shipFileRoutine(ctx context.Context, name string, sendQueue collectTime, err = time.Parse(time.RFC3339Nano, split[0]) if err != nil { promLineParsingErr.WithLabelValues(baseName).Add(1) + s.l.Error("parsing line time", zap.Error(err), zap.String("file", name)) } }