diff --git a/plugins/outputs/prometheus_client/prometheus_client.go b/plugins/outputs/prometheus_client/prometheus_client.go index b52dcff6d24c3..b555bfe1c5b7c 100644 --- a/plugins/outputs/prometheus_client/prometheus_client.go +++ b/plugins/outputs/prometheus_client/prometheus_client.go @@ -94,7 +94,9 @@ func (p *PrometheusClient) Connect() error { func (p *PrometheusClient) Close() error { ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() - return p.server.Shutdown(ctx) + err := p.server.Shutdown(ctx) + prometheus.Unregister(p) + return err } func (p *PrometheusClient) SampleConfig() string {