Add result related tags and fields to http_response (#3814)

This commit is contained in:
Germán Jaber
2018-03-08 16:55:59 -06:00
committed by Daniel Nelson
parent 8005883de8
commit 81a93fcddf
3 changed files with 496 additions and 111 deletions

View File

@@ -44,18 +44,38 @@ This input plugin will test HTTP/HTTPS connections.
### Measurements & Fields:
- http_response
- response_time (float, seconds)
- http_response_code (int) #The code received
- result_type (string) # success, timeout, response_string_mismatch, connection_failed
- response_time (float, seconds) # Not set if target is unreachable for any reason
- http_response_code (int) # The HTTP code received
- result_type (string) # Legacy field mantained for backwards compatibility
- result_code (int) # Details [here](#result-tag-and-result_code-field)
### Tags:
- All measurements have the following tags:
- server
- method
- server # Server URL used
- method # HTTP method used (GET, POST, PUT, etc)
- status_code # String with the HTTP status code
- result # Details [here](#result-tag-and-result_code-field)
### Result tag and Result_code field
Upon finishing polling the target server, the plugin registers the result of the operation in the `result` tag, and adds a numeric field called `result_code` corresponding with that tag value.
This tag is used to expose network and plugin errors. HTTP errors are considered a sucessful connection by the plugin.
|Tag value |Corresponding field value|Description|
--------------------------|-------------------------|-----------|
|success | 0 |The HTTP request completed, even if the HTTP code represents an error|
|response_string_mismatch | 1 |The option `response_string_match` was used, and the body of the response didn't match the regex|
|body_read_error | 2 |The option `response_string_match` was used, but the plugin wans't able to read the body of the response. Responses with empty bodies (like 3xx, HEAD, etc) will trigger this error|
|connection_failed | 3 |Catch all for any network error not specifically handled by the plugin|
|timeout | 4 |The plugin timed out while awaiting the HTTP connection to complete|
|dns_error | 5 |There was a DNS error while attempting to connect to the host|
NOTE: The error codes are derived from the error object returned by the `net/http` Go library, so the accuracy of the errors depends on the handling of error states by the `net/http` Go library. **If a more detailed error report is required use the `log_network_errors` setting.**
### Example Output:
```
http_response,method=GET,server=http://www.github.com http_response_code=200i,response_time=6.223266528 1459419354977857955
http_response,method=GET,server=http://www.github.com,status_code="200",result="success" http_response_code=200i,response_time=6.223266528,result_type="sucess",result_code=0i 1459419354977857955
```