From 55a9bc6872db09556d1a9f6bd2e85f40486c0abc Mon Sep 17 00:00:00 2001 From: Vijay Samuel Date: Wed, 26 Apr 2017 11:39:38 -0700 Subject: [PATCH] Fixing nil pointer on prometheus collector when http response is nil --- CHANGELOG.asciidoc | 1 + metricbeat/module/prometheus/collector/collector.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 5f5b51bc0c4..1edfbb55bf9 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -147,6 +147,7 @@ https://github.com/elastic/beats/compare/v5.1.1...master[Check the HEAD diff] - Add kubelet module {pull}3916[3916] - Add dropwizard module {pull}4022[4022] - Adding query APIs for metricsets and modules from metricbeat registry {pull}4102[4102] +- Fixing nil pointer on prometheus collector when http response is nil {pull}4119[4119] *Packetbeat* - Add `fields` and `fields_under_root` to packetbeat protocols configurations. {pull}3518[3518] diff --git a/metricbeat/module/prometheus/collector/collector.go b/metricbeat/module/prometheus/collector/collector.go index 5cb83d8ebed..77915b3caae 100644 --- a/metricbeat/module/prometheus/collector/collector.go +++ b/metricbeat/module/prometheus/collector/collector.go @@ -57,10 +57,10 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) { func (m *MetricSet) Fetch() ([]common.MapStr, error) { resp, err := m.http.FetchResponse() - defer resp.Body.Close() if err != nil { return nil, err } + defer resp.Body.Close() families, err := prometheus.GetMetricFamiliesFromResponse(resp) if err != nil {