Skip to content

Commit

Permalink
Return and log detailed services information on /ready (#2055)
Browse files Browse the repository at this point in the history
* Return and log detailed services information on /ready

This helps debug starting services more easily.

Signed-off-by: Dimitar Dimitrov <[email protected]>

* Only return non-running services

Signed-off-by: Dimitar Dimitrov <[email protected]>
  • Loading branch information
dimitarvdimitrov authored Jun 8, 2022
1 parent dd1c12a commit 716d0c6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/mimir/mimir.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,15 @@ func (t *Mimir) readyHandler(sm *services.Manager) http.HandlerFunc {
msg := bytes.Buffer{}
msg.WriteString("Some services are not Running:\n")

byState := sm.ServicesByState()
for st, ls := range byState {
msg.WriteString(fmt.Sprintf("%v: %d\n", st, len(ls)))
for name, s := range t.ServiceMap {
if s.State() != services.Running {
msg.WriteString(fmt.Sprintf("%s: %s\n", name, s.State()))
}
}

http.Error(w, msg.String(), http.StatusServiceUnavailable)
strMsg := msg.String()
level.Debug(util_log.Logger).Log(strMsg)
http.Error(w, strMsg, http.StatusServiceUnavailable)
return
}

Expand Down

0 comments on commit 716d0c6

Please sign in to comment.