http_response

package
v0.0.0-...-72bdc65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2016 License: MIT Imports: 8 Imported by: 0

README

Example Input Plugin

This input plugin will test HTTP/HTTPS connections.

Configuration:
# List of UDP/TCP connections you want to check
[[inputs.http_response]]
  ## Server address (default http://localhost)
  address = "http://github.com"
  ## Set response_timeout (default 5 seconds)
  response_timeout = 5
  ## HTTP Request Method
  method = "GET"
  ## HTTP Request Headers
  [inputs.http_response.headers]
      Host = github.com
  ## Whether to follow redirects from the server (defaults to false)
  follow_redirects = true
  ## Optional HTTP Request Body
  body = '''
  {'fake':'data'}
  '''
Measurements & Fields:
  • http_response
    • response_time (float, seconds)
    • http_response_code (int) #The code received
Tags:
  • All measurements have the following tags:
    • server
    • method
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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRedirectAttempted = errors.New("redirect")

ErrRedirectAttempted indicates that a redirect occurred

Functions

func CreateHeaders

func CreateHeaders(headers map[string]string) http.Header

CreateHeaders takes a map of header strings and puts them into a http.Header Object

func CreateHttpClient

func CreateHttpClient(followRedirects bool, ResponseTimeout time.Duration) *http.Client

CreateHttpClient creates an http client which will timeout at the specified timeout period and can follow redirects if specified

Types

type HTTPResponse

type HTTPResponse struct {
	Address         string
	Body            string
	Method          string
	ResponseTimeout int
	Headers         map[string]string
	FollowRedirects bool
}

HTTPResponse struct

func (*HTTPResponse) Description

func (h *HTTPResponse) Description() string

Description returns the plugin Description

func (*HTTPResponse) Gather

func (h *HTTPResponse) Gather(acc telegraf.Accumulator) error

Gather gets all metric fields and tags and returns any errors it encounters

func (*HTTPResponse) HTTPGather

func (h *HTTPResponse) HTTPGather() (map[string]interface{}, error)

HTTPGather gathers all fields and returns any errors it encounters

func (*HTTPResponse) SampleConfig

func (h *HTTPResponse) SampleConfig() string

SampleConfig returns the plugin SampleConfig

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL