From e3145a84d7547c5d169f636ddac61dc9a2a280b0 Mon Sep 17 00:00:00 2001 From: dongdong Date: Fri, 2 Aug 2024 17:48:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20operator=20scraper=20=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E8=AF=A6=E7=BB=86=E8=AF=B7=E6=B1=82=E5=A4=B1=E8=B4=A5=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=20--story=3D119013109=20(#470)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/operator/operator/scraper/scraper.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/operator/operator/scraper/scraper.go b/pkg/operator/operator/scraper/scraper.go index c01ee1f11..2cab20911 100644 --- a/pkg/operator/operator/scraper/scraper.go +++ b/pkg/operator/operator/scraper/scraper.go @@ -77,13 +77,14 @@ func (c *Scraper) StringCh() chan string { for _, host := range c.config.Hosts { resp, err := c.doRequest(host) if err != nil { + ch <- fmt.Sprintf("scraper error: host=%s, err=%v", host, err) continue } defer resp.Body.Close() - if resp.StatusCode >= 400 { + if resp.StatusCode >= 300 { b, _ := io.ReadAll(resp.Body) - msg := fmt.Sprintf("scrape error => status code: %v, response: %v", resp.StatusCode, string(b)) + msg := fmt.Sprintf("scraper error: host=%s, status_code=%d, response(%v)", host, resp.StatusCode, string(b)) ch <- msg continue }