diff --git a/plugins/outputs/loki/loki.go b/plugins/outputs/loki/loki.go index b12b0c6d60e73..e93b43c417265 100644 --- a/plugins/outputs/loki/loki.go +++ b/plugins/outputs/loki/loki.go @@ -189,7 +189,7 @@ func (l *Loki) writeMetrics(s Streams) error { if err != nil { return err } - _ = resp.Body.Close() + defer resp.Body.Close() if resp.StatusCode < 200 || resp.StatusCode >= 300 { body, _ := io.ReadAll(resp.Body)