From 98cd14987ab7417fd5369ab5e002675abaf9f5a6 Mon Sep 17 00:00:00 2001 From: Joshua Powers Date: Mon, 22 Jan 2024 12:05:24 -0700 Subject: [PATCH] fix(outputs.loki): Do not close body before reading it (#14604) --- plugins/outputs/loki/loki.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)