Merge pull request #205 from vmarmol/healthz
Add a /healthz endpoint to cAdvisor.
This commit is contained in:
commit
8dae6c43c0
@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/google/cadvisor/api"
|
"github.com/google/cadvisor/api"
|
||||||
"github.com/google/cadvisor/container/docker"
|
"github.com/google/cadvisor/container/docker"
|
||||||
"github.com/google/cadvisor/container/raw"
|
"github.com/google/cadvisor/container/raw"
|
||||||
|
"github.com/google/cadvisor/healthz"
|
||||||
"github.com/google/cadvisor/info"
|
"github.com/google/cadvisor/info"
|
||||||
"github.com/google/cadvisor/manager"
|
"github.com/google/cadvisor/manager"
|
||||||
"github.com/google/cadvisor/pages"
|
"github.com/google/cadvisor/pages"
|
||||||
@ -60,6 +61,11 @@ func main() {
|
|||||||
glog.Fatalf("raw registration failed: %v.", err)
|
glog.Fatalf("raw registration failed: %v.", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Basic health handler.
|
||||||
|
if err := healthz.RegisterHandler(); err != nil {
|
||||||
|
glog.Fatalf("failed to register healthz handler: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Handler for static content.
|
// Handler for static content.
|
||||||
http.HandleFunc(static.StaticResource, func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc(static.StaticResource, func(w http.ResponseWriter, r *http.Request) {
|
||||||
err := static.HandleRequest(w, r.URL)
|
err := static.HandleRequest(w, r.URL)
|
||||||
|
16
healthz/healthz.go
Normal file
16
healthz/healthz.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package healthz
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func handleHealthz(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte("ok"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register simple HTTP /healthz handler to return "ok".
|
||||||
|
func RegisterHandler() error {
|
||||||
|
http.HandleFunc("/healthz", handleHealthz)
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user