Skip to content
Snippets Groups Projects
Unverified Commit 95630fac authored by Antoine Leroyer's avatar Antoine Leroyer Committed by GitHub
Browse files

Merge pull request #7 from wikimedia/silent

Allow to silence "error handling stats line" messages
parents d08c20ec e0adec1f
No related branches found
No related tags found
No related merge requests found
......@@ -171,24 +171,37 @@ func (re *rsyslogExporter) Collect(ch chan<- prometheus.Metric) {
continue
}
labelValues := []string{}
if p.promLabelValue() != "" {
labelValues = []string{p.promLabelValue()}
}
metric := prometheus.MustNewConstMetric(
p.promDescription(),
p.promType(),
p.promValue(),
p.promLabelValue(),
labelValues...,
)
ch <- metric
}
}
func (re *rsyslogExporter) run() {
func (re *rsyslogExporter) run(silent bool) {
errorPoint := &point{
Name: "stats_line_errors",
Type: counter,
Description: "Counts errors during stats line handling",
}
re.set(errorPoint)
for re.scanner.Scan() {
err := re.handleStatLine(re.scanner.Bytes())
if err != nil {
errorPoint.Value += 1
if !silent {
log.Printf("error handling stats line: %v, line was: %s", err, re.scanner.Bytes())
}
}
}
if err := re.scanner.Err(); err != nil {
log.Printf("error reading input: %v", err)
}
......
2017-08-30T08:09:54.776051+00:00 some-node.example.org rsyslogd-pstats: { "name": "global", "origin": "dynstats", "values": { } }
2017-08-30T08:09:54.776052+00:00 some-node.example.org rsyslogd-pstats: { "name": "global", "origin": "percentile", "values": { } }
2017-08-30T08:09:54.776072+00:00 some-node.example.org rsyslogd-pstats: { "name": "imuxsock", "origin": "imuxsock", "submitted": 9, "ratelimit.discarded": 0, "ratelimit.numratelimiters": 0 }
2017-08-30T08:09:54.776082+00:00 some-node.example.org rsyslogd-pstats: { "name": "action 0", "origin": "core.action", "processed": 0, "failed": 0, "suspended": 0, "suspended.duration": 0, "resumed": 0 }
2017-08-30T08:09:54.776088+00:00 some-node.example.org rsyslogd-pstats: { "name": "to_exporter_2", "origin": "core.action", "processed": 0, "failed": 0, "suspended": 0, "suspended.duration": 0, "resumed": 0 }
......
......@@ -17,6 +17,7 @@ var (
metricPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.")
certPath = flag.String("tls.server-crt", "", "Path to PEM encoded file containing TLS server cert.")
keyPath = flag.String("tls.server-key", "", "Path to PEM encoded file containing TLS server key (unencyrpted).")
silent = flag.Bool("silent", false, "Disable logging of errors in handling stats lines")
)
func main() {
......@@ -37,7 +38,7 @@ func main() {
}()
go func() {
exporter.run()
exporter.run(*silent)
}()
prometheus.MustRegister(exporter)
......
......@@ -23,10 +23,14 @@ type point struct {
}
func (p *point) promDescription() *prometheus.Desc {
variableLabels := []string{}
if p.promLabelName() != "" {
variableLabels = []string{p.promLabelName()}
}
return prometheus.NewDesc(
prometheus.BuildFQName("", "rsyslog", p.Name),
p.Description,
[]string{p.promLabelName()},
variableLabels,
nil,
)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment