Skip to content

Commit

Permalink
fix: scraping failed when Content-Type header is not set (#24135)
Browse files Browse the repository at this point in the history
Co-authored-by: L1Cafe <L1Cafe@donotemail.me>
  • Loading branch information
L1Cafe and L1Cafe authored Mar 14, 2023
1 parent e1d0102 commit 5a7ce07
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gather/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ func (p *prometheusScraper) parse(r io.Reader, header http.Header, target influx
now := time.Now()

mediatype, params, err := mime.ParseMediaType(header.Get("Content-Type"))
if err != nil {
if err != nil && err.Error() == "mime: no media type" {
mediatype = "text/plain"
} else if err != nil {
return collected, err
}
// Prepare output
Expand Down

0 comments on commit 5a7ce07

Please sign in to comment.