httpjson

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2015 License: MIT Imports: 9 Imported by: 0

README

HTTP JSON Plugin

The httpjson plugin can collect data from remote URLs which respond with JSON. Then it flattens JSON and finds all numeric values, treating them as floats.

For example, if you have a service called mycollector, which has HTTP endpoint for gathering stats http://my.service.com/_stats:

[[httpjson.services]]
  name = "mycollector"

  servers = [
    "http://my.service.com/_stats"
  ]

  # HTTP method to use (case-sensitive)
  method = "GET"

The name is used as a prefix for the measurements.

The method specifies HTTP method to use for requests.

You can specify which keys from server response should be considered as tags:

[[httpjson.services]]
  ...

  tag_keys = [
    "role",
    "version"
  ]

NOTE: tag values should be strings.

You can also specify additional request parameters for the service:

[[httpjson.services]]
  ...

 [httpjson.services.parameters]
    event_type = "cpu_spike"
    threshold = "0.75"

Sample

Let's say that we have a service named "mycollector", which responds with:

{
    "a": 0.5,
    "b": {
        "c": "some text",
        "d": 0.1,
        "e": 5
    }
}

The collected metrics will be:

httpjson_mycollector_a value=0.5
httpjson_mycollector_b_d value=0.1
httpjson_mycollector_b_e value=5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPClient

type HTTPClient interface {
	// Returns the result of an http request
	//
	// Parameters:
	// req: HTTP request object
	//
	// Returns:
	// http.Response:  HTTP respons object
	// error        :  Any error that may have occurred
	MakeRequest(req *http.Request) (*http.Response, error)
}

type HttpJson

type HttpJson struct {
	Services []Service
	// contains filtered or unexported fields
}

func (*HttpJson) Description

func (h *HttpJson) Description() string

func (*HttpJson) Gather

func (h *HttpJson) Gather(acc plugins.Accumulator) error

Gathers data for all servers.

func (*HttpJson) SampleConfig

func (h *HttpJson) SampleConfig() string

type RealHTTPClient

type RealHTTPClient struct {
	// contains filtered or unexported fields
}

func (RealHTTPClient) MakeRequest

func (c RealHTTPClient) MakeRequest(req *http.Request) (*http.Response, error)

type Service

type Service struct {
	Name       string
	Servers    []string
	Method     string
	TagKeys    []string
	Parameters map[string]string
}

Jump to

Keyboard shortcuts

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