diff --git a/config/config.go b/config/config.go index b9935470..aac188cd 100644 --- a/config/config.go +++ b/config/config.go @@ -142,10 +142,11 @@ func (s *HTTPProbe) UnmarshalYAML(unmarshal func(interface{}) error) error { return errors.New("at most one of body & body_file may be configured") } if s.BodyFile != "" { - _, err := os.Open(s.BodyFile) + file, err := os.Open(s.BodyFile) if err != nil { return err } + defer file.Close() } return nil } diff --git a/prober/http.go b/prober/http.go index a88358c3..7f647aef 100644 --- a/prober/http.go +++ b/prober/http.go @@ -269,6 +269,7 @@ func ProbeHTTP(ctx context.Context, target string, module config.Module, registr level.Error(logger).Log("msg", "Error opening body file", "err", err) return } + defer file.Close() body = file }