metrics

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2017 License: Apache-2.0 Imports: 13 Imported by: 82

Documentation

Index

Constants

View Source
const (
	Gauge        MetricType = "gauge"
	Availability            = "availability"
	Counter                 = "counter"
	Generic                 = "metrics"
	String                  = "string"
)
View Source
const (
	// ASC Ascending
	ASC = iota
	// DESC Descending
	DESC
)

Variables

This section is empty.

Functions

func ConvertToFloat64

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

ConvertToFloat64 Return float64 from most numeric types

func FromUnixMilli added in v0.6.1

func FromUnixMilli(milli int64) time.Time

FromUnixMilli returns time.Time from milliseconds since epoch

func ToUnixMilli added in v0.6.1

func ToUnixMilli(t time.Time) int64

ToUnixMilli returns milliseconds since epoch from time.Time

func URLEscape added in v0.6.1

func URLEscape(input string) string

URLEscape Is a fixed version of Golang's URL escaping handling

Types

type Bucketpoint added in v0.5.2

type Bucketpoint struct {
	Start       time.Time    `json:"-"`
	End         time.Time    `json:"-"`
	Min         float64      `json:"min"`
	Max         float64      `json:"max"`
	Avg         float64      `json:"avg"`
	Median      float64      `json:"median"`
	Empty       bool         `json:"empty"`
	Samples     uint64       `json:"samples"`
	Percentiles []Percentile `json:"percentiles"`
}

Bucketpoint is a return structure for bucketed data requests (stats endpoint)

func (*Bucketpoint) UnmarshalJSON added in v0.6.1

func (b *Bucketpoint) UnmarshalJSON(payload []byte) error

UnmarshalJSON is a custom unmarshaller to transform int64 timestamps to time.Time

type Client

type Client struct {
	Tenant string

	Credentials string // base64 encoded username/password for Basic header
	Token       string // authentication token for Bearer header
	AdminToken  string // authentication for items behind admin token
	// contains filtered or unexported fields
}

Client is HawkularClient's internal data structure

func NewHawkularClient

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

NewHawkularClient returns a new initialized instance of client

func (*Client) AllDefinitions added in v0.6.1

func (c *Client) AllDefinitions(o ...Modifier) ([]*MetricDefinition, error)

AllDefinitions fetches all metric definitions (for every tenant) from the server. Requires admin/service rights

func (*Client) Close added in v0.6.0

func (c *Client) Close()

Close safely closes the Hawkular-Metrics client and flushes remaining writes to the server

func (*Client) Create

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

Create creates a new metric definition

func (*Client) CreateTenant added in v0.6.1

func (c *Client) CreateTenant(tenant TenantDefinition, o ...Modifier) (bool, error)

CreateTenant creates a tenant definition on the server

func (*Client) Definition

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

Definition returns a single metric definition

func (*Client) Definitions

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

Definitions fetches metric definitions from the server

func (*Client) DeleteTags

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

DeleteTags deletes given tags from the definition

func (*Client) ReadBuckets added in v0.5.2

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

ReadBuckets reads datapoints from the server, aggregated to buckets with given parameters.

func (*Client) ReadRaw added in v0.6.1

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

ReadRaw reads metric datapoints from the server for the given metric

func (*Client) Send added in v0.4.0

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

Send sends a constructed request to the Hawkular-Metrics server. All the requests are pooled and limited by set concurrency limits

func (*Client) TagValues added in v0.6.1

func (c *Client) TagValues(tagQuery map[string]string, o ...Modifier) (map[string][]string, error)

TagValues queries for available tagValues

func (*Client) Tags

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

Tags fetches metric definition's tags

func (*Client) Tenants added in v0.6.1

func (c *Client) Tenants(o ...Modifier) ([]*TenantDefinition, error)

Tenants returns a list of tenants from the server

func (*Client) URL added in v0.6.1

func (c *Client) URL(method string, e ...Endpoint) Modifier

URL sets the request URL

func (*Client) UpdateTags

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

UpdateTags modifies the tags of a metric definition

func (*Client) Write

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

Write writes datapoints to the server

type Datapoint

type Datapoint struct {
	Timestamp time.Time         `json:"-"`
	Value     interface{}       `json:"value"`
	Tags      map[string]string `json:"tags,omitempty"`
}

Datapoint is a struct that represents a single time series value. Value should be convertible to float64 for gauge/counter series. Timestamp accuracy is milliseconds since epoch

func (Datapoint) MarshalJSON added in v0.6.1

func (d Datapoint) MarshalJSON() ([]byte, error)

MarshalJSON is modified JSON marshalling for Datapoint object to modify time.Time to milliseconds since epoch

func (*Datapoint) UnmarshalJSON added in v0.6.1

func (d *Datapoint) UnmarshalJSON(b []byte) error

UnmarshalJSON is a custom unmarshaller for Datapoint for timestamp modifications

type Endpoint added in v0.4.0

type Endpoint func(u *url.URL)

Endpoint Endpoint type to define request URL

func OpenshiftEndpoint added in v0.6.1

func OpenshiftEndpoint() Endpoint

OpenshiftEndpoint is a URL endpoint only available in the origin-metrics installation

func RawEndpoint added in v0.6.1

func RawEndpoint() Endpoint

RawEndpoint is an endpoint to read and write raw datapoints

func SingleMetricEndpoint added in v0.4.0

func SingleMetricEndpoint(id string) Endpoint

SingleMetricEndpoint is a URL endpoint for requesting single metricID

func StatsEndpoint added in v0.6.1

func StatsEndpoint() Endpoint

StatsEndpoint is an endpoint to read aggregated metrics

func TagEndpoint added in v0.4.0

func TagEndpoint() Endpoint

TagEndpoint is a URL endpoint to check tags information

func TagNamesEndpoint added in v0.6.1

func TagNamesEndpoint(tagNames []string) Endpoint

TagNamesEndpoint is a URL endpoint which adds tags names (no values)

func TagsEndpoint added in v0.4.0

func TagsEndpoint(tags map[string]string) Endpoint

TagsEndpoint is a URL endpoint which adds tags query

func TenantEndpoint added in v0.6.1

func TenantEndpoint() Endpoint

TenantEndpoint is a URL endpoint to fetch tenant related information

func TypeEndpoint added in v0.4.0

func TypeEndpoint(t MetricType) Endpoint

TypeEndpoint is a URL endpoint setting metricType

type Filter added in v0.4.0

type Filter func(r *http.Request)

Filter Filter type for querying

func BucketsDurationFilter added in v0.6.1

func BucketsDurationFilter(duration time.Duration) Filter

BucketsDurationFilter is a query parameter to set the size of a bucket based on duration Minimum supported bucket is 1 millisecond

func BucketsFilter added in v0.4.0

func BucketsFilter(buckets int) Filter

BucketsFilter is a query parameter to define amount of buckets

func EndTimeFilter added in v0.4.0

func EndTimeFilter(endTime time.Time) Filter

EndTimeFilter is a query parameter to filter with end time

func IdFilter added in v0.4.0

func IdFilter(regexp string) Filter

IdFilter is a query parameter to add filtering by id name

func LimitFilter added in v0.6.0

func LimitFilter(limit int) Filter

LimitFilter is a query parameter to limit result count

func OrderFilter added in v0.6.0

func OrderFilter(order Order) Filter

OrderFilter Query parameter to define the ordering of datapoints

func Param added in v0.4.0

func Param(k string, v string) Filter

Param adds query parameters to the request

func PercentilesFilter added in v0.5.2

func PercentilesFilter(percentiles []float64) Filter

PercentilesFilter is a query parameter to define the requested percentiles

func StackedFilter added in v0.6.0

func StackedFilter() Filter

StackedFilter forces downsampling of stacked return values

func StartFromBeginningFilter added in v0.6.0

func StartFromBeginningFilter() Filter

StartFromBeginningFilter returns data from the oldest stored datapoint

func StartTimeFilter added in v0.4.0

func StartTimeFilter(startTime time.Time) Filter

StartTimeFilter is a query parameter to filter with start time

func TagsFilter added in v0.4.0

func TagsFilter(t map[string]string) Filter

TagsFilter is a query parameter to filter with tags query

func TagsQueryFilter added in v0.6.1

func TagsQueryFilter(query ...string) Filter

TagsQueryFilter is a query parameter for the new style tags query language

func TypeFilter added in v0.4.0

func TypeFilter(t MetricType) Filter

TypeFilter is a query parameter to filter by type

type HawkularClient added in v0.4.0

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

HawkularClient is a base type to define available functions of the client

type HawkularClientError

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

HawkularClientError Extracted error information from Hawkular-Metrics server

func (*HawkularClientError) Error

func (c *HawkularClientError) Error() string

type HawkularError

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

HawkularError is the return payload from Hawkular-Metrics if processing failed

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"`
}

MetricDefinition is a struct that describes the stored definition of a time serie

type MetricHeader

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

MetricHeader is the header struct for time series, which has identifiers (tenant, type, id) for uniqueness and []Datapoint to describe the actual time series values.

type MetricType

type MetricType string

MetricType restrictions

type Modifier added in v0.4.0

type Modifier func(*http.Request) error

Modifier Modifiers base type

func AdminAuthentication added in v0.6.1

func AdminAuthentication(token string) Modifier

AdminAuthentication function to add metrics' admin token to the request

func Data added in v0.4.0

func Data(data interface{}) Modifier

Data adds payload to the request

func Filters added in v0.4.0

func Filters(f ...Filter) Modifier

Filters allows using multiple Filter types in the same request

func Tenant added in v0.4.0

func Tenant(tenant string) Modifier

Tenant function replaces the Tenant in the request (instead of using the default in Client parameters)

type Order added in v0.6.0

type Order int

Order is a basetype for selecting the sorting of requested datapoints

func (Order) String added in v0.6.0

func (o Order) String() string

String returns a string representation of type

type Parameters

type Parameters struct {
	Tenant      string // Technically optional, but requires setting Tenant() option every time
	Url         string
	TLSConfig   *tls.Config
	Username    string
	Password    string
	Token       string
	Concurrency int
	AdminToken  string
}

Parameters is a struct used as initialization parameters to the client

type Percentile added in v0.5.2

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

Percentile is Hawkular-Metrics' estimated (not exact) percentile

type TenantDefinition added in v0.6.1

type TenantDefinition struct {
	ID         string             `json:"id"`
	Retentions map[MetricType]int `json:"retentions"`
}

TenantDefinition is the structure that defines a tenant

Jump to

Keyboard shortcuts

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