metrics

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2016 License: Apache-2.0 Imports: 12 Imported by: 87

Documentation

Index

Constants

View Source
const (
	Gauge = iota
	Availability
	Counter
	Generic
)

Variables

This section is empty.

Functions

func ConvertToFloat64

func ConvertToFloat64(v interface{}) (float64, error)

func UnixMilli

func UnixMilli(t time.Time) int64

Returns milliseconds since epoch

Types

type Bucketpoint added in v0.5.2

type Bucketpoint struct {
	Start       int64        `json:"start"`
	End         int64        `json:"end"`
	Min         float64      `json:"min"`
	Max         float64      `json:"max"`
	Avg         float64      `json:"avg"`
	Median      float64      `json:"median"`
	Empty       bool         `json:"empty"`
	Samples     int64        `json:"samples"`
	Percentiles []Percentile `json:"percentiles"`
}

TODO Fix the Start & End to return a time.Time

type Client

type Client struct {
	Tenant string

	Token string
	// contains filtered or unexported fields
}

func NewHawkularClient

func NewHawkularClient(p Parameters) (*Client, error)

func (*Client) Create

func (self *Client) Create(md MetricDefinition, o ...Modifier) (bool, error)

Create new Definition

func (*Client) Definition

func (self *Client) Definition(t MetricType, id string, o ...Modifier) (*MetricDefinition, error)

Return a single definition

func (*Client) Definitions

func (self *Client) Definitions(o ...Modifier) ([]*MetricDefinition, error)

Fetch definitions

func (*Client) DeleteTags

func (self *Client) DeleteTags(t MetricType, id string, tags map[string]string, o ...Modifier) error

Delete given tags from the definition

func (*Client) ReadBuckets added in v0.5.2

func (self *Client) ReadBuckets(t MetricType, o ...Modifier) ([]*Bucketpoint, error)

TODO ReadMetrics should be equal also, to read new tagsFilter aggregation..

func (*Client) ReadMetric added in v0.4.0

func (self *Client) ReadMetric(t MetricType, id string, o ...Modifier) ([]*Datapoint, error)

Read data from the server

func (*Client) Send added in v0.4.0

func (self *Client) Send(o ...Modifier) (*http.Response, error)

func (*Client) Tags

func (self *Client) Tags(t MetricType, id string, o ...Modifier) (map[string]string, error)

Fetch metric definition tags

func (*Client) UpdateTags

func (self *Client) UpdateTags(t MetricType, id string, tags map[string]string, o ...Modifier) error

Update tags

func (*Client) Url added in v0.4.0

func (self *Client) Url(method string, e ...Endpoint) Modifier

func (*Client) Write

func (self *Client) Write(metrics []MetricHeader, o ...Modifier) error

Write datapoints to the server

type Datapoint

type Datapoint struct {
	Timestamp int64             `json:"timestamp"`
	Value     interface{}       `json:"value"`
	Tags      map[string]string `json:"tags,omitempty"`
}

Value should be convertible to float64 for numeric values Timestamp is milliseconds since epoch

type Endpoint added in v0.4.0

type Endpoint func(u *url.URL)

func DataEndpoint added in v0.4.0

func DataEndpoint() Endpoint

func SingleMetricEndpoint added in v0.4.0

func SingleMetricEndpoint(id string) Endpoint

func TagEndpoint added in v0.4.0

func TagEndpoint() Endpoint

func TagsEndpoint added in v0.4.0

func TagsEndpoint(tags map[string]string) Endpoint

func TypeEndpoint added in v0.4.0

func TypeEndpoint(t MetricType) Endpoint

type Filter added in v0.4.0

type Filter func(r *http.Request)

func BucketsFilter added in v0.4.0

func BucketsFilter(buckets int) Filter

func EndTimeFilter added in v0.4.0

func EndTimeFilter(endTime time.Time) Filter

func IdFilter added in v0.4.0

func IdFilter(regexp string) Filter

Requires HWKMETRICS-233

func Param added in v0.4.0

func Param(k string, v string) Filter

Add query parameters

func PercentilesFilter added in v0.5.2

func PercentilesFilter(percentiles []float64) Filter

func StartTimeFilter added in v0.4.0

func StartTimeFilter(startTime time.Time) Filter

func TagsFilter added in v0.4.0

func TagsFilter(t map[string]string) Filter

func TypeFilter added in v0.4.0

func TypeFilter(t MetricType) Filter

type HawkularClient added in v0.4.0

type HawkularClient interface {
	Send(*http.Request) (*http.Response, error)
}

type HawkularClientError

type HawkularClientError struct {
	Code int
	// contains filtered or unexported fields
}

More detailed error

func (*HawkularClientError) Error

func (self *HawkularClientError) Error() string

type HawkularError

type HawkularError struct {
	ErrorMsg string `json:"errorMsg"`
}

type MetricDefinition

type MetricDefinition struct {
	Tenant        string            `json:"-"`
	Type          MetricType        `json:"type,omitempty"`
	Id            string            `json:"id"`
	Tags          map[string]string `json:"tags,omitempty"`
	RetentionTime int               `json:"dataRetention,omitempty"`
}

type MetricHeader

type MetricHeader struct {
	Tenant string      `json:"-"`
	Type   MetricType  `json:"-"`
	Id     string      `json:"id"`
	Data   []Datapoint `json:"data"`
}

type MetricType

type MetricType int

MetricType restrictions

func (MetricType) MarshalJSON added in v0.4.0

func (self MetricType) MarshalJSON() ([]byte, error)

func (MetricType) String

func (self MetricType) String() string

func (*MetricType) UnmarshalJSON added in v0.4.0

func (self *MetricType) UnmarshalJSON(b []byte) error

Custom unmarshaller

type Modifier added in v0.4.0

type Modifier func(*http.Request) error

func Data added in v0.4.0

func Data(data interface{}) Modifier

Add payload to the request

func Filters added in v0.4.0

func Filters(f ...Filter) Modifier

func Tenant added in v0.4.0

func Tenant(tenant string) Modifier

Override function to replace the Tenant (defaults to Client default)

type Parameters

type Parameters struct {
	Tenant    string // Technically optional, but requires setting Tenant() option everytime
	Url       string
	TLSConfig *tls.Config
	Token     string
}

type Percentile added in v0.5.2

type Percentile struct {
	Quantile float64 `json:"quantile"`
	Value    float64 `json:"value"`
}

type SortKey added in v0.4.0

type SortKey struct {
	Tenant string
	Type   MetricType
}

Jump to

Keyboard shortcuts

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