Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pkg/handler/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,13 @@ func getLokiError(resp []byte, code int) (int, string) {
hlog.WithError(err).Errorf("cannot unmarshal, response was: %v", string(resp))
return http.StatusBadRequest, fmt.Sprintf("Unknown error from Loki\ncannot unmarshal\n%s", resp)
}
message, ok := f["message"]
message, ok := f["error"]
if !ok {
return http.StatusBadRequest, "Unknown error from Loki\nno message found"
message, ok = f["message"]
if !ok {
hlog.WithError(err).Errorf("unknown Loki error: %v", f)
return http.StatusBadRequest, "Unknown error from Loki"
}
}
return http.StatusBadRequest, fmt.Sprintf("Loki message: %s", message)
}
Expand Down Expand Up @@ -135,6 +139,7 @@ func executeLokiQuery(flowsURL string, lokiClient httpclient.Caller) ([]byte, in
}
if code != http.StatusOK {
newCode, msg := getLokiError(resp, code)
hlog.Debugf("executeLokiQuery error: [%d] %s", code, msg)
return nil, newCode, fmt.Errorf("Error from Loki query: [%d] %s", code, msg)
}
return resp, http.StatusOK, nil
Expand All @@ -151,6 +156,7 @@ func getLokiLabelValues(baseURL string, lokiClient httpclient.Caller, label stri
}
if code != http.StatusOK {
newCode, msg := getLokiError(resp, code)
hlog.Debugf("getLokiLabelValues error: [%d] %s", code, msg)
return nil, newCode, errors.New(msg)
}
hlog.Tracef("getLokiLabelValues raw response: %s", resp)
Expand Down
Loading