From c1c75dd76bc221de4009851e26599a0b6c63c640 Mon Sep 17 00:00:00 2001 From: Phil Porada Date: Fri, 4 Aug 2017 15:47:26 -0400 Subject: [PATCH] Changed the logging to use the prometheus logger --- unbound_exporter.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/unbound_exporter.go b/unbound_exporter.go index 9978e7c..1cb0312 100644 --- a/unbound_exporter.go +++ b/unbound_exporter.go @@ -21,13 +21,13 @@ import ( "fmt" "io" "io/ioutil" - "log" "net/http" "os" "regexp" "strconv" "strings" + "github.com/prometheus/common/log" "github.com/prometheus/client_golang/prometheus" ) @@ -251,7 +251,6 @@ func CollectFromReader(file io.Reader, ch chan<- prometheus.Metric) error { scanner.Text()) } - gotMatch := false for _, metric := range unboundMetrics { matches := metric.pattern.FindStringSubmatch(fields[0]) if matches != nil { @@ -265,14 +264,9 @@ func CollectFromReader(file io.Reader, ch chan<- prometheus.Metric) error { value, matches[1:]...) - gotMatch = true break } } - if !gotMatch { - // log.Printf("Metric %q doesn't match and pattern!", fields[0]) - } - } return scanner.Err() } @@ -352,7 +346,7 @@ func (e *UnboundExporter) Collect(ch chan<- prometheus.Metric) { prometheus.GaugeValue, 1.0) } else { - log.Printf("Failed to scrape socket: %s", err) + log.Error("Failed to scrape socket: %s", err) ch <- prometheus.MustNewConstMetric( unboundUpDesc, prometheus.GaugeValue, @@ -371,6 +365,7 @@ func main() { ) flag.Parse() + log.Info("Starting unbound_exporter") exporter, err := NewUnboundExporter(*unboundHost, *unboundCa, *unboundCert, *unboundKey) if err != nil { panic(err) @@ -388,5 +383,6 @@ func main() { `)) }) + log.Info("Listening on", *listenAddress) log.Fatal(http.ListenAndServe(*listenAddress, nil)) }