@@ -10,6 +10,7 @@ import (
1010 "strings"
1111
1212 "github.com/hpcloud/tail"
13+ "github.com/prometheus/client_golang/prometheus"
1314
1415 "github.com/letsencrypt/boulder/cmd"
1516 blog "github.com/letsencrypt/boulder/log"
@@ -83,21 +84,27 @@ func main() {
8384 }
8485
8586 var config struct {
86- Syslog cmd.SyslogConfig
87- Files []string
87+ Syslog cmd.SyslogConfig
88+ DebugAddr string
89+ Files []string
8890 }
8991 configBytes , err := ioutil .ReadFile (* configPath )
9092 cmd .FailOnError (err , "failed to read config file" )
9193 err = json .Unmarshal (configBytes , & config )
9294 cmd .FailOnError (err , "failed to parse config file" )
9395
94- logger := cmd .NewLogger (config .Syslog )
96+ stats , logger := cmd .StatsAndLogging (config .Syslog , config .DebugAddr )
97+ badLineCounter := prometheus .NewCounterVec (prometheus.CounterOpts {
98+ Name : "bad_log_lines" ,
99+ Help : "A counter of corrupt log lines" ,
100+ }, []string {"filename" })
101+ stats .MustRegister (badLineCounter )
95102
96103 var tailers []* tail.Tail
97104 for _ , filename := range config .Files {
98105 t , err := tail .TailFile (filename , tail.Config {
99106 ReOpen : true ,
100- MustExist : true ,
107+ MustExist : false , // sometimes files won't exist, so we must tolerate that
101108 Follow : true ,
102109 })
103110 cmd .FailOnError (err , "failed to tail file" )
@@ -110,6 +117,7 @@ func main() {
110117 continue
111118 }
112119 if err := lineValid (line .Text ); err != nil {
120+ badLineCounter .WithLabelValues (t .Filename ).Inc ()
113121 logger .Errf ("%s: %s %q" , t .Filename , err , line .Text )
114122 }
115123 }
0 commit comments