prometheus

package
v0.0.0-...-449ccef Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2015 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package prometheus provides bindings to the Prometheus HTTP API: http://prometheus.io/docs/querying/api/

Index

Constants

View Source
const (
	// The different API error types.
	ErrBadData     ErrorType = "bad_data"
	ErrTimeout               = "timeout"
	ErrCanceled              = "canceled"
	ErrExec                  = "execution"
	ErrBadResponse           = "bad_response"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CancelableTransport

type CancelableTransport interface {
	http.RoundTripper
	CancelRequest(req *http.Request)
}

CancelableTransport is like net.Transport but provides per-request cancelation functionality.

var DefaultTransport CancelableTransport = &http.Transport{
	Proxy: http.ProxyFromEnvironment,
	Dial: (&net.Dialer{
		Timeout:   30 * time.Second,
		KeepAlive: 30 * time.Second,
	}).Dial,
	TLSHandshakeTimeout: 10 * time.Second,
}

type Client

type Client interface {
	// contains filtered or unexported methods
}

func New

func New(cfg Config) (Client, error)

New returns a new Client.

type Config

type Config struct {
	// The address of the Prometheus to connect to.
	Address string

	// Transport is used by the Client to drive HTTP requests. If not
	// provided, DefaultTransport will be used.
	Transport CancelableTransport
}

Config defines configuration parameters for a new client.

type Error

type Error struct {
	Type ErrorType
	Msg  string
}

Error is an error returned by the API.

func (*Error) Error

func (e *Error) Error() string

type ErrorType

type ErrorType string

type QueryAPI

type QueryAPI interface {
	// Query performs a query for the given time.
	Query(ctx context.Context, query string, ts time.Time) (model.Value, error)
	// Query performs a query for the given range.
	QueryRange(ctx context.Context, query string, r Range) (model.Value, error)
}

QueryAPI provides bindings the Prometheus's query API.

func NewQueryAPI

func NewQueryAPI(c Client) QueryAPI

NewQueryAPI returns a new QueryAPI for the client.

type Range

type Range struct {
	// The boundaries of the time range.
	Start, End time.Time
	// The maximum time between two slices within the boundaries.
	Step time.Duration
}

Range represents a sliced time range.

Jump to

Keyboard shortcuts

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