From 55cfd5c904c619f8a3ce6dbf6e6a1504adff6692 Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Wed, 8 Jul 2015 21:28:25 +0200 Subject: [PATCH] Check that API reponse is 200. --- plugins/elasticsearch/elasticsearch.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/elasticsearch/elasticsearch.go b/plugins/elasticsearch/elasticsearch.go index 79b2435c2..74428680d 100644 --- a/plugins/elasticsearch/elasticsearch.go +++ b/plugins/elasticsearch/elasticsearch.go @@ -70,6 +70,9 @@ func (e *Elasticsearch) gatherUrl(url string, acc plugins.Accumulator) error { if err != nil { return err } + if r.StatusCode != http.StatusOK { + return fmt.Errorf("elasticsearch: API responded with status-code %d, expected %d", r.StatusCode, http.StatusOK) + } d := json.NewDecoder(r.Body) esRes := &struct { ClusterName string `json:"cluster_name"`