Skip to content

Commit

Permalink
add more logs for plugin http_response
Browse files Browse the repository at this point in the history
  • Loading branch information
UlricQin committed Dec 16, 2022
1 parent f0b8628 commit 763db05
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions inputs/http_response/http_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ func (ins *Instance) httpGather(target string) (map[string]string, map[string]in
// If an error in returned, it means we are dealing with a network error, as
// HTTP error codes do not generate errors in the net/http library
if err != nil {
if config.Config.DebugMode {
log.Println("D! network error while polling:", target, "error:", err)
}
log.Println("E! network error while polling:", target, "error:", err)

// metric: result_code
fields["result_code"] = ConnectionFailed
Expand Down Expand Up @@ -280,12 +278,14 @@ func (ins *Instance) httpGather(target string) (map[string]string, map[string]in

if len(ins.ExpectResponseSubstring) > 0 {
if !strings.Contains(string(bs), ins.ExpectResponseSubstring) {
log.Println("E! body mismatch, response body:", string(bs))
fields["result_code"] = BodyMismatch
}
}

if ins.ExpectResponseStatusCode != nil {
if *ins.ExpectResponseStatusCode != resp.StatusCode {
log.Println("E! status code mismatch, response stats code:", resp.StatusCode)
fields["result_code"] = CodeMismatch
}
}
Expand Down

0 comments on commit 763db05

Please sign in to comment.