diff --git a/metricbeat/module/traefik/health/health.go b/metricbeat/module/traefik/health/health.go index 78d04438ef53..619d4444db9b 100644 --- a/metricbeat/module/traefik/health/health.go +++ b/metricbeat/module/traefik/health/health.go @@ -63,11 +63,10 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) { // Fetch methods gather data, convert it to the right format, and publish it. // If there are errors, those are published instead. -func (m *MetricSet) Fetch(report mb.ReporterV2) { +func (m *MetricSet) Fetch(reporter mb.ReporterV2) error { data, err := m.http.FetchJSON() if err != nil { - report.Error(errors.Wrap(err, "failed to sample health")) - return + return errors.Wrap(err, "failed to sample health") } metricSetFields, _ := eventMapping(data) @@ -77,5 +76,6 @@ func (m *MetricSet) Fetch(report mb.ReporterV2) { } event.RootFields.Put("service.name", "traefik") - report.Event(event) + reporter.Event(event) + return nil } diff --git a/metricbeat/module/traefik/health/health_integration_test.go b/metricbeat/module/traefik/health/health_integration_test.go index 7147b590c525..aa2a15308bfe 100644 --- a/metricbeat/module/traefik/health/health_integration_test.go +++ b/metricbeat/module/traefik/health/health_integration_test.go @@ -48,7 +48,7 @@ func TestFetch(t *testing.T) { makeBadRequest(config) - ms := mbtest.NewReportingMetricSetV2(t, config) + ms := mbtest.NewReportingMetricSetV2Error(t, config) reporter := &mbtest.CapturingReporterV2{} ms.Fetch(reporter) diff --git a/metricbeat/module/traefik/health/health_test.go b/metricbeat/module/traefik/health/health_test.go index 0671f2cece95..bec941dffea1 100644 --- a/metricbeat/module/traefik/health/health_test.go +++ b/metricbeat/module/traefik/health/health_test.go @@ -49,7 +49,7 @@ func TestFetchEventContents(t *testing.T) { "hosts": []string{server.URL}, } - fetcher := mbtest.NewReportingMetricSetV2(t, config) + fetcher := mbtest.NewReportingMetricSetV2Error(t, config) reporter := &mbtest.CapturingReporterV2{} fetcher.Fetch(reporter)