diff --git a/pkg/tsdb/influxdb/influxdb.go b/pkg/tsdb/influxdb/influxdb.go index ec1e9ff01bd..3ee6b8a30d6 100644 --- a/pkg/tsdb/influxdb/influxdb.go +++ b/pkg/tsdb/influxdb/influxdb.go @@ -4,16 +4,16 @@ import ( "context" "encoding/json" "fmt" + "io/ioutil" "net/http" "net/url" "path" - "golang.org/x/net/context/ctxhttp" - "github.com/grafana/grafana/pkg/log" "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/tsdb" + "golang.org/x/net/context/ctxhttp" ) type InfluxDBExecutor struct { @@ -71,13 +71,14 @@ func (e *InfluxDBExecutor) Query(ctx context.Context, dsInfo *models.DataSource, return nil, err } + defer resp.Body.Close() if resp.StatusCode/100 != 2 { + ioutil.ReadAll(resp.Body) return nil, fmt.Errorf("Influxdb returned statuscode invalid status code: %v", resp.Status) } var response Response dec := json.NewDecoder(resp.Body) - defer resp.Body.Close() dec.UseNumber() err = dec.Decode(&response)