graphite

package
v0.0.0-...-cbea63e Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Children

func Children(q string) ([]string, error)

Children wraps DefaultConnection.Children()

Types

type Connection

type Connection struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Connection represents a connection to Grapnite

var DefaultConnection *Connection = NewConnection()

DefaultConnection is used, by default, to execute Query()

func NewConnection

func NewConnection() *Connection

NewConnection mints a new Graphite connection which listens for config changes

func (*Connection) Children

func (conn *Connection) Children(q string) ([]string, error)

Children returns a list of target IDs within a specific node in the target tree An example q would be `stats.com.hailocab` to find all child nodes of this

func (*Connection) Query

func (conn *Connection) Query(path string, v url.Values) ([]byte, error)

Query executes a query to fetch data from graphite - returning raw JSON-encoded bytes The supplied URL values will be augmented with hostname, port

type DataPoint

type DataPoint struct {
	X, Y *float64
}

type Query

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

func NewQuery

func NewQuery() *Query

NewQuery mints a new Graphite query from 24 hours ago with no targets (need to be added)

func (*Query) AddTarget

func (q *Query) AddTarget(t string) *Query

AddTarget adds a single target metric (incl. Graphite function(s)) to the query

func (*Query) Execute

func (q *Query) Execute() (*Result, error)

Execute hits Graphite and returns results

func (*Query) From

func (q *Query) From(from time.Time) *Query

From sets the from time, with an open-ended to

func (*Query) Range

func (q *Query) Range(from, to time.Time) *Query

Range zeros in on a specific start/end time

type Result

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

func (*Result) Count

func (r *Result) Count() int

Count returns how many series we have within this results set

func (*Result) Current

func (r *Result) Current() *Series

Current returns the current item within the iterator

func (*Result) Next

func (r *Result) Next() bool

NextItem can be called inside `for` and will populate the response to Current() Responds with true if a new Current() was found (hence you can call Current() to get it)

func (*Result) Rewind

func (r *Result) Rewind()

Rewind takes the result set iterator back to the start

func (*Result) Target

func (r *Result) Target(s string) *Series

Target attempts to find the result for a particular target, returning nil if not found

func (*Result) TargetLike

func (r *Result) TargetLike(s string) *Series

TargetLike attempts to find the result for a particular target, matching where the supplied string is _anywhere_ within the target name - eg: partial match. Returns nil if not found This will always return the _first_ thing found that matches, where multiple matches exist

func (*Result) TargetN

func (r *Result) TargetN(i int) *Series

TargetN returns the Nth results series, 0 indexed, or nil if out of bounds

type Series

type Series struct {
	Name       string
	DataPoints []DataPoint
	// contains filtered or unexported fields
}

func (*Series) Current

func (tr *Series) Current() DataPoint

Current returns the current data point within the iterator

func (*Series) Len

func (tr *Series) Len() int

Len returns how many data points in a series

func (*Series) Max

func (tr *Series) Max() float64

Max finds the maximum Y value from the data points within the series Will return 0 if no datapoints

func (*Series) Min

func (tr *Series) Min() float64

Min finds the minimunm Y value from the data points within the series Will return 0 if no datapoints

func (*Series) Next

func (tr *Series) Next() bool

NextItem can be called inside `for` and will populate the response to Current() Responds with true if a new Current() was found (hence you can call Current() to get it)

func (*Series) Rewind

func (tr *Series) Rewind()

Rewind takes the result set iterator back to the start

func (*Series) Sum

func (tr *Series) Sum() float64

Sum will aggregate all Y values from data points within the series

Jump to

Keyboard shortcuts

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