Prometheusとgrafanaのhealth checkのpath、なんかしっくりこなかったので調べてみた
Prometheus
health check endpoint実装されてた
router.Get("/-/healthy", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Prometheus is Healthy.\n")
})
router.Get("/-/ready", readyf(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Prometheus is Ready.\n")
}))
揉めずにサクッとはいっていた模様。/-/ready
が先にあったからかな?
Add /-/healthy
and /-/ready
endpoints #2831
deployment
シンプルになった 😇
livenessProbe:
httpGet:
path: /-/healthy
port: 9090
readinessProbe:
httpGet:
path: /-/ready
port: 9090
Grafana
Grafana 4.3で /api/health
endpointが提供されていた。
func (hs *HTTPServer) healthHandler(ctx *macaron.Context) {
notHeadOrGet := ctx.Req.Method != http.MethodGet && ctx.Req.Method != http.MethodHead
if notHeadOrGet || ctx.Req.URL.Path != "/api/health" {
return
}
data := simplejson.New()
data.Set("database", "ok")
data.Set("version", setting.BuildVersion)
data.Set("commit", setting.BuildCommit)
ぼちぼちコメントがある。それなりにこまっていたということだろうか?ぼちぼちコメントが有る。
grafanaのiconが帰ってくるかどうかでwork aroundしているひともいるぐらい。
アクセスすると認証前だったらlogin画面に飛ばされたり、そもそもそのログイン画面がちょいと重かったりする(所感)
deployment
シンプルになった 😇
readinessProbe:
httpGet:
path: /api/health
port: 3000
総論
health check先が提供されていると良いよね