package metrics

import "github.com/hawkular/hawkular-client-go/metrics"

Index

Constants

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

Functions

func ConvertToFloat64

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

ConvertToFloat64 Return float64 from most numeric types

func FromUnixMilli

func FromUnixMilli(milli int64) time.Time

FromUnixMilli returns time.Time from milliseconds since epoch

func ToUnixMilli

func ToUnixMilli(t time.Time) int64

ToUnixMilli returns milliseconds since epoch from time.Time

func URLEscape

func URLEscape(input string) string

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

Types

type Bucketpoint

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

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

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

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

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

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

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

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

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

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

Tenants returns a list of tenants from the server

func (*Client) URL

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

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

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

UnmarshalJSON is a custom unmarshaller for Datapoint for timestamp modifications

type Endpoint

type Endpoint func(u *url.URL)

Endpoint Endpoint type to define request URL

func OpenshiftEndpoint

func OpenshiftEndpoint() Endpoint

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

func RawEndpoint

func RawEndpoint() Endpoint

RawEndpoint is an endpoint to read and write raw datapoints

func SingleMetricEndpoint

func SingleMetricEndpoint(id string) Endpoint

SingleMetricEndpoint is a URL endpoint for requesting single metricID

func StatsEndpoint

func StatsEndpoint() Endpoint

StatsEndpoint is an endpoint to read aggregated metrics

func TagEndpoint

func TagEndpoint() Endpoint

TagEndpoint is a URL endpoint to check tags information

func TagNamesEndpoint

func TagNamesEndpoint(tagNames []string) Endpoint

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

func TagsEndpoint

func TagsEndpoint(tags map[string]string) Endpoint

TagsEndpoint is a URL endpoint which adds tags query

func TenantEndpoint

func TenantEndpoint() Endpoint

TenantEndpoint is a URL endpoint to fetch tenant related information

func TypeEndpoint

func TypeEndpoint(t MetricType) Endpoint

TypeEndpoint is a URL endpoint setting metricType

type Filter

type Filter func(r *http.Request)

Filter Filter type for querying

func BucketsDurationFilter

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

func BucketsFilter(buckets int) Filter

BucketsFilter is a query parameter to define amount of buckets

func EndTimeFilter

func EndTimeFilter(endTime time.Time) Filter

EndTimeFilter is a query parameter to filter with end time

func IdFilter

func IdFilter(regexp string) Filter

IdFilter is a query parameter to add filtering by id name

func LimitFilter

func LimitFilter(limit int) Filter

LimitFilter is a query parameter to limit result count

func OrderFilter

func OrderFilter(order Order) Filter

OrderFilter Query parameter to define the ordering of datapoints

func Param

func Param(k string, v string) Filter

Param adds query parameters to the request

func PercentilesFilter

func PercentilesFilter(percentiles []float64) Filter

PercentilesFilter is a query parameter to define the requested percentiles

func StackedFilter

func StackedFilter() Filter

StackedFilter forces downsampling of stacked return values

func StartFromBeginningFilter

func StartFromBeginningFilter() Filter

StartFromBeginningFilter returns data from the oldest stored datapoint

func StartTimeFilter

func StartTimeFilter(startTime time.Time) Filter

StartTimeFilter is a query parameter to filter with start time

func TagsFilter

func TagsFilter(t map[string]string) Filter

TagsFilter is a query parameter to filter with tags query

func TagsQueryFilter

func TagsQueryFilter(query ...string) Filter

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

func TypeFilter

func TypeFilter(t MetricType) Filter

TypeFilter is a query parameter to filter by type

type HawkularClient

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

type Modifier func(*http.Request) error

Modifier Modifiers base type

func AdminAuthentication

func AdminAuthentication(token string) Modifier

AdminAuthentication function to add metrics' admin token to the request

func Data

func Data(data interface{}) Modifier

Data adds payload to the request

func Filters

func Filters(f ...Filter) Modifier

Filters allows using multiple Filter types in the same request

func Tenant

func Tenant(tenant string) Modifier

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

type Order

type Order int

Order is a basetype for selecting the sorting of requested datapoints

func (Order) String

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

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

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

type TenantDefinition

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

TenantDefinition is the structure that defines a tenant

Source Files

client.go helpers.go types.go

Version
v0.6.1 (latest)
Published
Dec 14, 2017
Platform
js/wasm
Imports
13 packages
Last checked
2 weeks ago

Tools for package owners.