builder

package
v0.0.0-...-fea1ff7 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2017 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Metric Errors.
	ErrorMetricNameInvalid = errors.New("Metric name empty")
	ErrorTagNameInvalid    = errors.New("Tag name empty")
	ErrorTagValueInvalid   = errors.New("Tag value empty")
	ErrorTTLInvalid        = errors.New("TTL value invalid")

	// Data Point Errors.
	ErrorDataPointInt64   = errors.New("Not an int64 data value")
	ErrorDataPointFloat64 = errors.New("Not a float64 data value")

	// Query Metric Errors.
	ErrorQMetricNameInvalid     = errors.New("Query Metric name empty")
	ErrorQMetricTagNameInvalid  = errors.New("Query Metric Tag name empty")
	ErrorQMetricTagValueInvalid = errors.New("Query Metric Tag value empty")
	ErrorQMetricLimitInvalid    = errors.New("Query Metric Limit must be >= 0")

	// Query Builder Errors.
	ErrorAbsRelativeStartSet      = errors.New("Both absolute and relative start times cannot be set")
	ErrorRelativeStartTimeInvalid = errors.New("Relative start time duration must be > 0")
	ErrorAbsRelativeEndSet        = errors.New("Both absolute and relative end times cannot be set")
	ErrorRelativeEndTimeInvalid   = errors.New("Relative end time duration must be > 0")
	ErrorStartTimeNotSpecified    = errors.New("Start time not specified")
)

Functions

This section is empty.

Types

type Aggregator

type Aggregator interface {
	// Returns the name of the aggregation being used.
	Name() string

	// Validates that the contents of the aggregator.
	Validate() error
}

func CreateAverageAggregator

func CreateAverageAggregator(value int, unit utils.TimeUnit) Aggregator

Creates an aggregator that returns the average values for each time period as specified. For example, "5 minutes" would returns the average value for each 5 minute period.

@param value value for time period. @param unit unit of time @return average aggregator

func CreateCountAggregator

func CreateCountAggregator(value int, unit utils.TimeUnit) Aggregator

Creates an aggregator that returns the count of all values for each time period as specified. For example, "5 minutes" would returns the count of data points for each 5 minute period.

@param value value for time period. @param unit unit of time @return count aggregator

func CreateDataGapsMarkingAggregator

func CreateDataGapsMarkingAggregator(value int, unit utils.TimeUnit) Aggregator

Creates an aggregator that marks gaps in data according to sampling rate with a null data point.

@param value value for time period. @param unit unit of time @return gap marking aggregator

func CreateDiffAggregator

func CreateDiffAggregator() Aggregator

Creates an aggregator that computes the difference between successive data points.

@return diff aggregator

func CreateDivAggregator

func CreateDivAggregator(divisor float64) Aggregator

Creates an aggregator that divides each value by the divisor.

@param divisor divisor. @return div aggregator

func CreateFirstAggregator

func CreateFirstAggregator(value int, unit utils.TimeUnit) Aggregator

Creates an aggregator that returns the first data point for the time range.

@param value value for time period. @param unit unit of time @return first aggregator

func CreateLastAggregator

func CreateLastAggregator(value int, unit utils.TimeUnit) Aggregator

Creates an aggregator that returns the last data point for the time range.

@param value value for time period. @param unit unit of time @return last aggregator

func CreateLeastSquaresAggregator

func CreateLeastSquaresAggregator(value int, unit utils.TimeUnit) Aggregator

Creates an aggregator that returns a best fit line through the datapoints using the least squares algorithm..

@param value value for time period. @param unit unit of time @return least squares aggregator

func CreateMaxAggregator

func CreateMaxAggregator(value int, unit utils.TimeUnit) Aggregator

Creates an aggregator that returns the maximum values for each time period as specified. For example, "5 minutes" would returns the maximum value for each 5 minute period.

@param value value for time period. @param unit unit of time @return max aggregator

func CreateMinAggregator

func CreateMinAggregator(value int, unit utils.TimeUnit) Aggregator

Creates an aggregator that returns the minimum values for each time period as specified. For example, "5 minutes" would returns the minimum value for each 5 minute period.

@param value value for time period. @param unit unit of time @return min aggregator

func CreatePercentileAggregator

func CreatePercentileAggregator(percentile float64, value int, unit utils.TimeUnit) Aggregator

Creates an aggregator that returns the percentile value for a given percentage of all values over each time period as specified. For example, "0.5" and "5 minutes" would returns the median of data points for each 5 minute period.

@param value percentage @param unit unit of time @return percentile aggregator

func CreateRateAggregator

func CreateRateAggregator(unit utils.TimeUnit) Aggregator

Creates an aggregator that returns the rate of change between each pair of data points

@param unit unit of time @return rate aggregator

func CreateSamplerAggregator

func CreateSamplerAggregator() Aggregator

Creates an aggregator that computes the sampling rate of change for the data points.

@return sampler aggregator

func CreateSaveAsAggregator

func CreateSaveAsAggregator(newMetricName string) Aggregator

Creates an aggregator that saves the results of the query to a new metric.

@param newMetricName metric to save results to @return save as aggregator

func CreateScaleAggregator

func CreateScaleAggregator(factor float64) Aggregator

Creates an aggregator that scales each data point by a factor.

@param factor factor to scale by @return sampler aggregator

func CreateStandardDeviationAggregator

func CreateStandardDeviationAggregator(value int, unit utils.TimeUnit) Aggregator

Creates an aggregator that returns the standard deviation values for each time period as specified. For example, "5 minutes" would returns the standard deviation value for each 5 minute period.

@param value value for time period. @param unit unit of time @return standard deviation aggregator

func CreateSumAggregator

func CreateSumAggregator(value int, unit utils.TimeUnit) Aggregator

Creates an aggregator that returns the sum of all values over each time period as specified. For example, "5 minutes" would returns the sum value for each 5 minute period.

@param value value for time period. @param unit unit of time @return sum aggregator

func CreateTrimAggregator

func CreateTrimAggregator(trim TrimType) Aggregator

Creates an aggregator that trim of the first, last, or both data points returned by the query.

@param trim what to trim @return trim aggregator

type DataPoint

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

Represents a measurement. Stores the time when the measurement occurred and its value.

func NewDataPoint

func NewDataPoint(ts int64, val interface{}) *DataPoint

func (*DataPoint) Float64Value

func (dp *DataPoint) Float64Value() (float64, error)

func (*DataPoint) Int64Value

func (dp *DataPoint) Int64Value() (int64, error)

func (*DataPoint) MarshalJSON

func (dp *DataPoint) MarshalJSON() ([]byte, error)

func (*DataPoint) Timestamp

func (dp *DataPoint) Timestamp() int64

func (*DataPoint) UnmarshalJSON

func (dp *DataPoint) UnmarshalJSON(data []byte) error

type Metric

type Metric interface {
	// Adds a TTL, expressed in seconds, to the metric.
	AddTTL(ttl int64) Metric

	// Adds a custom type of value stored in datapoint.
	AddType(t string) Metric

	// Adds a tag to the datapoint.
	AddTag(name, val string) Metric

	// Add a map of tags. This narrows the query to only show data points
	// associated with the tags' values.
	AddTags(tags map[string]string) Metric

	// Adds a datapoint to the metric. The value is of int64 type.
	AddDataPoint(timestamp int64, value interface{}) Metric

	// Returns the TLL associated with the metric.
	GetTTL() int64

	// Returns the name of the metric.
	GetName() string

	// Returns the custom type name.
	GetType() string

	// Returns all the tags/values as a map.
	GetTags() map[string]string

	// Returns an array of all the datapoints of this metric.
	GetDataPoints() []DataPoint

	// Encodes the Metric instance as a JSON array.
	Build() ([]byte, error)
	// contains filtered or unexported methods
}

An interface that represents an instance of a metric.

func NewMetric

func NewMetric(name string) Metric

type MetricBuilder

type MetricBuilder interface {
	// Add a new metric to the builder.
	AddMetric(name string) Metric

	// Get a list of all the metrics that are part of the builder.
	GetMetrics() []Metric

	// Encode the Metrics list into JSON.
	Build() ([]byte, error)
}

func NewMetricBuilder

func NewMetricBuilder() MetricBuilder

type OrderType

type OrderType string
const (
	ASCENDING  OrderType = "asc"
	DESCENDING OrderType = "desc"
)

type QueryBuilder

type QueryBuilder interface {
	// The beginning time in the time range.
	SetAbsoluteStart(date time.Time) QueryBuilder

	// The beginning time of the time range relative to now.
	SetRelativeStart(duration int, unit utils.TimeUnit) QueryBuilder

	// The ending value of the time range. Must be later in time than the
	// start time. An end time is not required and default to now.
	SetAbsoluteEnd(date time.Time) QueryBuilder

	// The ending time of the time range relative to now.
	SetRelativeEnd(duration int, unit utils.TimeUnit) QueryBuilder

	// How long to cache this exact query. The default is to never cache.
	SetCacheTime(cacheTimeMs int) QueryBuilder

	// The metric to query for.
	AddMetric(name string) QueryMetric

	// Returns the absolute range start time.
	AbsoluteStart() time.Time

	// Returns the relative range start time.
	RelativeStart() *utils.RelativeTime

	// Returns the absolute range end time.
	AbsoluteEnd() time.Time

	// Returns the relative range end time.
	RelativeEnd() *utils.RelativeTime

	// Returns the Cache time.
	CacheTime() int

	// Returns array of metrics.
	Metrics() []QueryMetric

	// Encodes the QueryBuilder into JSON.
	Build() ([]byte, error)
}

func NewQueryBuilder

func NewQueryBuilder() QueryBuilder

type QueryMetric

type QueryMetric interface {
	// Add a map of tags. This narrows the query to only show data points
	// associated with the tags' values.
	AddTags(tags map[string][]string) QueryMetric

	// Adds a tag with multiple values. This narrows the query to only show
	// data points associated with the tag's values.
	AddTag(name string, val []string) QueryMetric

	// Adds an aggregator to the metric.
	AddAggregator(aggr Aggregator) QueryMetric

	// Adds a grouper to the metric.
	AddGrouper() QueryMetric

	// Exclude tag for find instead of include them.
	SetExcludeTags(excludeTags bool) QueryMetric

	// Limits the number of data point returned from the query.
	// The limit is done before aggregators are executed.
	SetLimit(limit int) QueryMetric

	// Orders the data points. The server default is ascending.
	SetOrder(order OrderType) QueryMetric

	// Validates the contents of the QueryMetric instance.
	Validate() error
}

func NewQueryMetric

func NewQueryMetric(name string) QueryMetric

type TrimType

type TrimType string
const (
	TRIM_FIRST TrimType = "first"
	TRIM_LAST  TrimType = "last"
	TRIM_BOTH  TrimType = "both"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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