Skip to content

Commit

Permalink
IG-11657: Add health check logs. (#38)
Browse files Browse the repository at this point in the history
* IG-11657: Add health check logs.

* Revert change to imports.

* Add more logs.
  • Loading branch information
gtopper authored and gshatz committed Apr 30, 2019
1 parent f2c5c70 commit 47575ff
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,15 @@ func New(logger log.Logger, o *Options) *Handler {
router.Get("/-/healthy", func(w http.ResponseWriter, r *http.Request) {
if o.V3ioConfig == nil {
w.WriteHeader(http.StatusInternalServerError)
level.Warn(h.logger).Log("msg", "Prometheus is Unhealthy: still waiting on V3IO storage.")
fmt.Fprintf(w, "Prometheus is Unhealthy: still waiting on V3IO storage.\n")
return
}
schemaUrl := "http://" + path.Join(o.V3ioConfig.WebApiEndpoint, o.V3ioConfig.Container, o.V3ioConfig.TablePath, ".schema")
req, err := http.NewRequest("GET", schemaUrl, nil)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
level.Warn(h.logger).Log("msg", "Prometheus is Unhealthy.", "error", err)
fmt.Fprintf(w, "Prometheus is Unhealthy: %v\n", err)
return
}
Expand All @@ -363,24 +365,29 @@ func New(logger log.Logger, o *Options) *Handler {
resp, err := client.Do(req)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
level.Warn(h.logger).Log("msg", "Prometheus is Unhealthy.", "error", err)
fmt.Fprintf(w, "Prometheus is Unhealthy: %v\n", err)
return
}
if resp.StatusCode != http.StatusOK {
w.WriteHeader(http.StatusInternalServerError)
level.Warn(h.logger).Log("msg", "Prometheus is Unhealthy because it could not find schema file.", "schemaUrl", schemaUrl, "response", resp)
fmt.Fprintf(w, "Prometheus is Unhealthy because it could not find %s: %+v\n", schemaUrl, resp)
return
}
w.WriteHeader(http.StatusOK)
level.Info(h.logger).Log("msg", "Prometheus is Healthy.")
fmt.Fprintf(w, "Prometheus is Healthy.\n")
})
router.Get("/-/ready", readyf(func(w http.ResponseWriter, r *http.Request) {
if o.V3ioConfig == nil {
w.WriteHeader(http.StatusInternalServerError)
level.Warn(h.logger).Log("msg", "Prometheus is not ready: still waiting on V3IO storage.")
fmt.Fprintf(w, "Prometheus is not ready: still waiting on V3IO storage.\n")
return
}
w.WriteHeader(http.StatusOK)
level.Info(h.logger).Log("msg", "Prometheus is Ready.")
fmt.Fprintf(w, "Prometheus is Ready.\n")
}))

Expand Down

0 comments on commit 47575ff

Please sign in to comment.