Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
# rsyslog_exporter [![Build Status](https://travis-ci.org/digitalocean/rsyslog_exporter.svg?branch=master)](https://travis-ci.org/digitalocean/rsyslog_exporter) # 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. 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 ## Rsyslog Configuration
...@@ -21,6 +22,8 @@ ruleset(name="process_stats") { ...@@ -21,6 +22,8 @@ ruleset(name="process_stats") {
} }
``` ```
The exporter itself logs back via syslog, this cannot be configured at the moment.
## Provided Metrics ## Provided Metrics
The following metrics provided by the rsyslog impstats module are tracked by rsyslog_exporter: 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) { ...@@ -138,13 +138,15 @@ func (re *rsyslogExporter) Collect(ch chan<- prometheus.Metric) {
func (re *rsyslogExporter) run() { func (re *rsyslogExporter) run() {
for re.scanner.Scan() { for re.scanner.Scan() {
log.Printf("received line: %s", re.scanner.Bytes())
err := re.handleStatLine(re.scanner.Bytes()) err := re.handleStatLine(re.scanner.Bytes())
if err != nil { if err != nil {
log.Print(err) log.Printf("error handling stats line: %v", err)
} }
} }
if err := re.scanner.Err(); err != nil { if err := re.scanner.Err(); err != nil {
log.Printf("error reading input: %v", err) log.Printf("error reading input: %v", err)
} }
log.Print("input ended, exiting normally")
os.Exit(0) os.Exit(0)
} }
...@@ -3,6 +3,7 @@ package main ...@@ -3,6 +3,7 @@ package main
import ( import (
"flag" "flag"
"log" "log"
"log/syslog"
"net/http" "net/http"
"os" "os"
"os/signal" "os/signal"
...@@ -16,6 +17,11 @@ var ( ...@@ -16,6 +17,11 @@ var (
) )
func main() { func main() {
logwriter, e := syslog.New(syslog.LOG_NOTICE, "rsyslog_exporter")
if e == nil {
log.SetOutput(logwriter)
}
flag.Parse() flag.Parse()
exporter := newRsyslogExporter() exporter := newRsyslogExporter()
...@@ -23,6 +29,7 @@ func main() { ...@@ -23,6 +29,7 @@ func main() {
c := make(chan os.Signal, 1) c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt) signal.Notify(c, os.Interrupt)
<-c <-c
log.Print("interrupt received, exiting")
os.Exit(0) os.Exit(0)
}() }()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment