mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-21 12:16:36 +00:00
Use the new prometheus http API (#71)
* Use the new prometheus http API The new recommended way of using the prometheus http handler is through the promhttp package: https://github.com/prometheus/client_golang/releases/tag/v0.8.0 (Separated HTTP exposition, allowing custom HTTP handlers (package promhttp)) * ListenAndServe always returns a non-nil error * updated vendored dependencies
This commit is contained in:
committed by
Martin Lindhe
parent
9d515255a6
commit
6bb522b6c3
@@ -15,6 +15,7 @@ import (
|
||||
|
||||
"github.com/martinlindhe/wmi_exporter/collector"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/prometheus/common/log"
|
||||
"github.com/prometheus/common/version"
|
||||
)
|
||||
@@ -177,7 +178,7 @@ func main() {
|
||||
nodeCollector := WmiCollector{collectors: collectors}
|
||||
prometheus.MustRegister(nodeCollector)
|
||||
|
||||
http.Handle(*metricsPath, prometheus.Handler())
|
||||
http.Handle(*metricsPath, promhttp.Handler())
|
||||
http.HandleFunc("/health", healthCheck)
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, *metricsPath, http.StatusMovedPermanently)
|
||||
@@ -188,9 +189,7 @@ func main() {
|
||||
|
||||
go func() {
|
||||
log.Infoln("Starting server on", *listenAddress)
|
||||
if err := http.ListenAndServe(*listenAddress, nil); err != nil {
|
||||
log.Fatalf("cannot start WMI exporter: %s", err)
|
||||
}
|
||||
log.Fatalf("cannot start WMI exporter: %s", http.ListenAndServe(*listenAddress, nil))
|
||||
}()
|
||||
|
||||
for {
|
||||
|
||||
Reference in New Issue
Block a user