Merge pull request #3 from pgporada/master
Changed the logging to use the prometheus logger
This commit is contained in:
commit
f538243789
|
@ -21,7 +21,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -29,6 +28,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
"github.com/prometheus/common/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -251,7 +251,6 @@ func CollectFromReader(file io.Reader, ch chan<- prometheus.Metric) error {
|
||||||
scanner.Text())
|
scanner.Text())
|
||||||
}
|
}
|
||||||
|
|
||||||
gotMatch := false
|
|
||||||
for _, metric := range unboundMetrics {
|
for _, metric := range unboundMetrics {
|
||||||
matches := metric.pattern.FindStringSubmatch(fields[0])
|
matches := metric.pattern.FindStringSubmatch(fields[0])
|
||||||
if matches != nil {
|
if matches != nil {
|
||||||
|
@ -265,14 +264,9 @@ func CollectFromReader(file io.Reader, ch chan<- prometheus.Metric) error {
|
||||||
value,
|
value,
|
||||||
matches[1:]...)
|
matches[1:]...)
|
||||||
|
|
||||||
gotMatch = true
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !gotMatch {
|
|
||||||
// log.Printf("Metric %q doesn't match and pattern!", fields[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return scanner.Err()
|
return scanner.Err()
|
||||||
}
|
}
|
||||||
|
@ -352,7 +346,7 @@ func (e *UnboundExporter) Collect(ch chan<- prometheus.Metric) {
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
1.0)
|
1.0)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("Failed to scrape socket: %s", err)
|
log.Error("Failed to scrape socket: %s", err)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
unboundUpDesc,
|
unboundUpDesc,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
@ -371,6 +365,7 @@ func main() {
|
||||||
)
|
)
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
log.Info("Starting unbound_exporter")
|
||||||
exporter, err := NewUnboundExporter(*unboundHost, *unboundCa, *unboundCert, *unboundKey)
|
exporter, err := NewUnboundExporter(*unboundHost, *unboundCa, *unboundCert, *unboundKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -388,5 +383,6 @@ func main() {
|
||||||
</body>
|
</body>
|
||||||
</html>`))
|
</html>`))
|
||||||
})
|
})
|
||||||
|
log.Info("Listening on address:port => ", *listenAddress)
|
||||||
log.Fatal(http.ListenAndServe(*listenAddress, nil))
|
log.Fatal(http.ListenAndServe(*listenAddress, nil))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue