log errors in lines, and ignore empty lines
This commit is contained in:
		| @@ -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)) | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user