resolves issues where failed api calls lead to obscure errors (#7051)

This commit is contained in:
Steven Soroka
2020-02-19 21:46:08 -05:00
committed by GitHub
parent 3058308d38
commit 5023df08d8
11 changed files with 97 additions and 16 deletions

View File

@@ -181,6 +181,7 @@ func (g *haproxy) gatherServer(addr string, acc telegraf.Accumulator) error {
if err != nil {
return fmt.Errorf("Unable to connect to haproxy server '%s': %s", addr, err)
}
defer res.Body.Close()
if res.StatusCode != 200 {
return fmt.Errorf("Unable to get valid stat result from '%s', http response code : %d", addr, res.StatusCode)