2018-03-08 23:13:26 +00:00
# HTTP Response Input Plugin
2016-03-31 07:33:28 +00:00
2018-03-08 23:13:26 +00:00
This input plugin checks HTTP/HTTPS connections.
2016-03-31 07:33:28 +00:00
### Configuration:
```
2016-05-23 12:33:43 +00:00
# HTTP/HTTPS request given an address a method and a timeout
2016-03-31 07:33:28 +00:00
[[inputs.http_response]]
2019-06-14 19:03:44 +00:00
## Deprecated in 1.12, use 'urls'
2016-03-31 10:18:19 +00:00
## Server address (default http://localhost)
2017-08-15 18:50:08 +00:00
# address = "http://localhost"
2019-06-14 19:03:44 +00:00
## List of urls to query.
# urls = ["http://localhost"]
2018-03-30 18:10:49 +00:00
## Set http_proxy (telegraf uses the system wide proxy settings if it's is not set)
# http_proxy = "http://localhost:8888"
2016-04-07 01:57:49 +00:00
## Set response_timeout (default 5 seconds)
2017-08-15 18:50:08 +00:00
# response_timeout = "5s"
2016-03-31 11:06:47 +00:00
## HTTP Request Method
2017-08-15 18:50:08 +00:00
# method = "GET"
2016-03-31 10:18:19 +00:00
## Whether to follow redirects from the server (defaults to false)
2017-08-15 18:50:08 +00:00
# follow_redirects = false
2016-03-31 11:06:47 +00:00
## Optional HTTP Request Body
2016-05-23 12:33:43 +00:00
# body = '''
# {'fake':'data'}
# '''
2016-05-25 11:41:21 +00:00
2019-01-07 19:25:08 +00:00
## Optional substring or regex match in body of the response (case sensitive)
2017-08-15 18:50:08 +00:00
# response_string_match = "\"service_status\": \"up\""
# response_string_match = "ok"
# response_string_match = "\".*_status\".?:.?\"up\""
2017-02-01 14:21:08 +00:00
2018-05-04 23:33:23 +00:00
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
2016-05-25 11:41:21 +00:00
# insecure_skip_verify = false
2017-08-15 18:50:08 +00:00
## HTTP Request Headers (all values must be strings)
# [inputs.http_response.headers]
# Host = "github.com"
2019-06-19 20:40:53 +00:00
2020-05-26 22:52:13 +00:00
## Optional setting to map reponse http headers into tags
## If the http header is not present on the request, no corresponding tag will be added
## If multiple instances of the http header are present, only the first value will be used
# http_header_tags = {"HTTP_HEADER" = "TAG_NAME"}
2019-06-19 20:40:53 +00:00
## Interface to use when dialing an address
# interface = "eth0"
2016-03-31 07:33:28 +00:00
```
2018-03-08 23:13:26 +00:00
### Metrics:
2016-03-31 07:33:28 +00:00
- http_response
2018-03-08 23:13:26 +00:00
- tags:
- server (target URL)
- method (request method)
- status_code (response status code)
- result ([see below](#result--result_code))
- fields:
- response_time (float, seconds)
2019-08-16 22:45:20 +00:00
- content_length (int, response body length)
2019-01-07 19:25:08 +00:00
- response_string_match (int, 0 = mismatch / body read error, 1 = match)
2018-03-08 23:13:26 +00:00
- http_response_code (int, response status code)
- result_type (string, deprecated in 1.6: use `result` tag and `result_code` field)
- result_code (int, [see below ](#result--result_code ))
#### `result` / `result_code`
2018-03-08 22:55:59 +00:00
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.
2018-03-08 23:13:26 +00:00
This tag is used to expose network and plugin errors. HTTP errors are considered a successful connection.
2018-03-08 22:55:59 +00:00
|Tag value |Corresponding field value|Description|
--------------------------|-------------------------|-----------|
|success | 0 |The HTTP request completed, even if the HTTP code represents an error|
2019-01-07 19:25:08 +00:00
|response_string_mismatch | 1 |The option `response_string_match` was used, and the body of the response didn't match the regex. HTTP errors with content in their body (like 4xx, 5xx) will trigger this error|
2020-02-18 22:30:56 +00:00
|body_read_error | 2 |The option `response_string_match` was used, but the plugin wasn't able to read the body of the response. Responses with empty bodies (like 3xx, HEAD, etc) will trigger this error|
2018-03-08 22:55:59 +00:00
|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|
2016-03-31 07:33:28 +00:00
### Example Output:
```
2019-08-16 22:45:20 +00:00
http_response,method=GET,result=success,server=http://github.com,status_code=200 content_length=87878i,http_response_code=200i,response_time=0.937655534,result_code=0i,result_type="success" 1565839598000000000
2016-03-31 07:33:28 +00:00
```