diff --git a/README.md b/README.md index f6f23157e1f9c723edc90a08c97641c6368994af..7a7d5863c040742be5c0f28eb5d73f88fd388ace 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # rsyslog_exporter [](https://travis-ci.org/digitalocean/rsyslog_exporter) + A [prometheus](http://prometheus.io/) exporter for [rsyslog](http://rsyslog.com). It accepts rsyslog [impstats](http://www.rsyslog.com/doc/master/configuration/modules/impstats.html) metrics in JSON format over stdin via the rsyslog [omprog](http://www.rsyslog.com/doc/v8-stable/configuration/modules/omprog.html) plugin and transforms and exposes them for consumption by Prometheus. ## Rsyslog Configuration @@ -21,6 +22,8 @@ ruleset(name="process_stats") { } ``` +The exporter itself logs back via syslog, this cannot be configured at the moment. + ## Provided Metrics The following metrics provided by the rsyslog impstats module are tracked by rsyslog_exporter: diff --git a/exporter.go b/exporter.go index 5d2fdf2b97fa332d1fbbdaabd04d25ce1bd73821..76f353d27fe4a2484b8db3ccb80354590b7c0647 100644 --- a/exporter.go +++ b/exporter.go @@ -138,13 +138,15 @@ func (re *rsyslogExporter) Collect(ch chan<- prometheus.Metric) { func (re *rsyslogExporter) run() { for re.scanner.Scan() { + log.Printf("received line: %s", re.scanner.Bytes()) err := re.handleStatLine(re.scanner.Bytes()) if err != nil { - log.Print(err) + log.Printf("error handling stats line: %v", err) } } if err := re.scanner.Err(); err != nil { log.Printf("error reading input: %v", err) } + log.Print("input ended, exiting normally") os.Exit(0) } diff --git a/main.go b/main.go index 3d83d1a76d7f837f42916fac046f8b86418d409b..fcd26d951f640901828385ec0b8edeea6612c6e8 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "flag" "log" + "log/syslog" "net/http" "os" "os/signal" @@ -16,6 +17,11 @@ var ( ) func main() { + logwriter, e := syslog.New(syslog.LOG_NOTICE, "rsyslog_exporter") + if e == nil { + log.SetOutput(logwriter) + } + flag.Parse() exporter := newRsyslogExporter() @@ -23,6 +29,7 @@ func main() { c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) <-c + log.Print("interrupt received, exiting") os.Exit(0) }()