infrastructure

package module
v0.0.0-...-d93bf4b Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2015 License: MIT Imports: 9 Imported by: 0

README

Graphite API

A simple client to query the Graphite URL API.

No external dependencies are required (except Go standard library, that is).

How to install

Use go get:

go get github.com/JensRantil/graphite-client

Documentation

Documentation can be found at http://godoc.org/github.com/JensRantil/graphite-client.

A great document summarizing the Graphite API can be found here.

Example

import (
  "time"
  graphite "github.com/JensRantil/graphite-client"
)

func init() {
  client, err := graphite.New("http://mygraphite.com/render/")
  checkError(err)
  interval := TimeInterval{time.Now().Add(-10 * time.Minutes), time.Now()}
  values, err := client.QueryInts("myhost.category.value", interval.TimeInterval{time.})
  // ...

  // Equivalent to the query above.
  values, err := client.QueryIntsSince("myhost.category.value", 10 * time.Minutes)
  // ...
}

Contributing

Feel free to fork at contribute pull requests. Please to add tests for new feature and run them using go test.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	URL    httpurl.URL
	Client *http.Client
}

func New

func New(url string) (*Client, error)

Create a new Client from a given URL. The URL is the base adress to Graphite, ie. without "/render" suffix etc.

func NewFromURL

func NewFromURL(url httpurl.URL) *Client

Create a new Client from a given URL. The URL is the base adress to Graphite, ie. without "/render" suffix etc.

func (*Client) Find

func (g *Client) Find(query string, opts *FindOpts) ([]FindResultItem, error)

func (*Client) Query

func (g *Client) Query(q string, interval TimeInterval) Datapoints

Fetches a Graphite result only expecting one timeseries. Deferring identifying whether the result are ints of floats to later. Useful in clients that executes adhoc queries.

func (*Client) QueryFloats

func (g *Client) QueryFloats(q string, interval TimeInterval) ([]FloatDatapoint, error)

Helper method to make it easier to create an interface for Client.

func (*Client) QueryFloatsSince

func (g *Client) QueryFloatsSince(q string, ago time.Duration) ([]FloatDatapoint, error)

Helper method to make it easier to create an interface for Client.

func (*Client) QueryInts

func (g *Client) QueryInts(q string, interval TimeInterval) ([]IntDatapoint, error)

Helper method to make it easier to create an interface for Client.

func (*Client) QueryIntsSince

func (g *Client) QueryIntsSince(q string, ago time.Duration) ([]IntDatapoint, error)

Helper method to make it easier to create an interface for Client.

func (*Client) QueryMulti

func (g *Client) QueryMulti(q []string, interval TimeInterval) (MultiDatapoints, error)

Fetches one or multiple Graphite series. Deferring identifying whether the result are ints of floats to later. Useful in clients that executes adhoc queries.

func (*Client) QueryMultiSince

func (g *Client) QueryMultiSince(q []string, ago time.Duration) (MultiDatapoints, error)

Fetches one or multiple Graphite series. Deferring identifying whether the result are ints of floats to later. Useful in clients that executes adhoc queries.

func (*Client) QuerySince

func (g *Client) QuerySince(q string, ago time.Duration) Datapoints

type Datapoints

type Datapoints struct {
	Target string
	// contains filtered or unexported fields
}

func (Datapoints) AsFloats

func (d Datapoints) AsFloats() ([]FloatDatapoint, error)

func (Datapoints) AsInts

func (d Datapoints) AsInts() ([]IntDatapoint, error)

type FindOpts

type FindOpts struct {
	From  *time.Time
	Until *time.Time
}

type FindResultItem

type FindResultItem struct {
	Leaf          bool
	Text          string
	Id            string
	Expandable    bool
	AllowChildren bool
}

type FloatDatapoint

type FloatDatapoint struct {
	Time  time.Time
	Value *float64
}

type IntDatapoint

type IntDatapoint struct {
	Time  time.Time
	Value *int64
}

type MultiDatapoints

type MultiDatapoints []Datapoints

type TimeInterval

type TimeInterval struct {
	From time.Time
	To   time.Time
}

func (*TimeInterval) Check

func (t *TimeInterval) Check() error

Jump to

Keyboard shortcuts

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