fix(outputs.loki): return response body on error (#12399)

This commit is contained in:
Joshua Powers 2022-12-16 06:18:43 -07:00 committed by GitHub
parent 02699341e7
commit 754ab64959
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -180,7 +180,8 @@ func (l *Loki) writeMetrics(s Streams) error {
_ = resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return fmt.Errorf("when writing to [%s] received status code: %d", l.url, resp.StatusCode)
body, _ := io.ReadAll(resp.Body)
return fmt.Errorf("when writing to [%s] received status code, %d: %s", l.url, resp.StatusCode, body)
}
return nil