Commit ec80fc01 authored by Matthias Rampke's avatar Matthias Rampke Committed by ale
Browse files

Log to syslog

when the exporter runs, we can assume that syslog is available. I don't
think stdout goes anywhere. Add and expand a few log messages. Log every
stats line as it is received, before processing.
parent deaaad36
# rsyslog_exporter [![Build Status](https://travis-ci.org/digitalocean/rsyslog_exporter.svg?branch=master)](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:
......
......@@ -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)
}
......@@ -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)
}()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment