mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2025-01-10 14:35:26 +00:00
Merge pull request #339 from yaron-idan/add-health-endpoint
add healthcheck endpoint
This commit is contained in:
commit
cba4a0783a
1 changed files with 17 additions and 0 deletions
17
main.go
17
main.go
|
@ -15,6 +15,7 @@ package main
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
|
@ -494,6 +495,22 @@ func main() {
|
|||
})
|
||||
}
|
||||
|
||||
mux.HandleFunc("/-/healthy", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == http.MethodGet {
|
||||
level.Debug(logger).Log("msg", "Received health check")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
fmt.Fprintf(w, "Statsd Exporter is Healthy.\n")
|
||||
}
|
||||
})
|
||||
|
||||
mux.HandleFunc("/-/ready", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == http.MethodGet {
|
||||
level.Debug(logger).Log("msg", "Received ready check")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
fmt.Fprintf(w, "Statsd Exporter is Ready.\n")
|
||||
}
|
||||
})
|
||||
|
||||
go serveHTTP(mux, *listenAddress, logger)
|
||||
|
||||
signals := make(chan os.Signal, 1)
|
||||
|
|
Loading…
Reference in a new issue