Merge pull request #339 from yaron-idan/add-health-endpoint

add healthcheck endpoint
This commit is contained in:
Matthias Rampke 2020-10-15 07:01:42 +00:00 committed by GitHub
commit cba4a0783a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

17
main.go
View file

@ -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)