From 09153c815cecec68508018e1b3828fc016a5b9c8 Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Tue, 15 Aug 2017 11:50:08 -0700 Subject: [PATCH] Move http_response headers to end of configuration. If the subtable comes before other options, they will be placed in the subtable. --- plugins/inputs/http_response/README.md | 26 +++++++++++-------- plugins/inputs/http_response/http_response.go | 25 +++++++++++------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/plugins/inputs/http_response/README.md b/plugins/inputs/http_response/README.md index 866fcbb23..924d35384 100644 --- a/plugins/inputs/http_response/README.md +++ b/plugins/inputs/http_response/README.md @@ -8,25 +8,26 @@ This input plugin will test HTTP/HTTPS connections. # HTTP/HTTPS request given an address a method and a timeout [[inputs.http_response]] ## Server address (default http://localhost) - address = "http://github.com" + # address = "http://localhost" + ## Set response_timeout (default 5 seconds) - response_timeout = "5s" + # response_timeout = "5s" + ## HTTP Request Method - method = "GET" + # method = "GET" + ## Whether to follow redirects from the server (defaults to false) - follow_redirects = true - ## HTTP Request Headers (all values must be strings) - # [inputs.http_response.headers] - # Host = "github.com" + # follow_redirects = false + ## Optional HTTP Request Body # body = ''' # {'fake':'data'} # ''' ## Optional substring or regex match in body of the response - ## response_string_match = "\"service_status\": \"up\"" - ## response_string_match = "ok" - ## response_string_match = "\".*_status\".?:.?\"up\"" + # response_string_match = "\"service_status\": \"up\"" + # response_string_match = "ok" + # response_string_match = "\".*_status\".?:.?\"up\"" ## Optional SSL Config # ssl_ca = "/etc/telegraf/ca.pem" @@ -34,6 +35,10 @@ This input plugin will test HTTP/HTTPS connections. # ssl_key = "/etc/telegraf/key.pem" ## Use SSL but skip chain & host verification # insecure_skip_verify = false + + ## HTTP Request Headers (all values must be strings) + # [inputs.http_response.headers] + # Host = "github.com" ``` ### Measurements & Fields: @@ -52,6 +57,5 @@ This input plugin will test HTTP/HTTPS connections. ### Example Output: ``` -$ ./telegraf --config telegraf.conf --input-filter http_response --test http_response,method=GET,server=http://www.github.com http_response_code=200i,response_time=6.223266528 1459419354977857955 ``` diff --git a/plugins/inputs/http_response/http_response.go b/plugins/inputs/http_response/http_response.go index f3deaf9e3..62d6e9ec1 100644 --- a/plugins/inputs/http_response/http_response.go +++ b/plugins/inputs/http_response/http_response.go @@ -47,25 +47,26 @@ func (h *HTTPResponse) Description() string { var sampleConfig = ` ## Server address (default http://localhost) - address = "http://github.com" + # address = "http://localhost" + ## Set response_timeout (default 5 seconds) - response_timeout = "5s" + # response_timeout = "5s" + ## HTTP Request Method - method = "GET" + # method = "GET" + ## Whether to follow redirects from the server (defaults to false) - follow_redirects = true - ## HTTP Request Headers (all values must be strings) - # [inputs.http_response.headers] - # Host = "github.com" + # follow_redirects = false + ## Optional HTTP Request Body # body = ''' # {'fake':'data'} # ''' ## Optional substring or regex match in body of the response - ## response_string_match = "\"service_status\": \"up\"" - ## response_string_match = "ok" - ## response_string_match = "\".*_status\".?:.?\"up\"" + # response_string_match = "\"service_status\": \"up\"" + # response_string_match = "ok" + # response_string_match = "\".*_status\".?:.?\"up\"" ## Optional SSL Config # ssl_ca = "/etc/telegraf/ca.pem" @@ -73,6 +74,10 @@ var sampleConfig = ` # ssl_key = "/etc/telegraf/key.pem" ## Use SSL but skip chain & host verification # insecure_skip_verify = false + + ## HTTP Request Headers (all values must be strings) + # [inputs.http_response.headers] + # Host = "github.com" ` // SampleConfig returns the plugin SampleConfig