opentsdb

package
v0.0.0-...-b425644 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(newLogger Logger)

Types

type DefaultLogger

type DefaultLogger struct {
}

func (*DefaultLogger) Debug

func (logger *DefaultLogger) Debug(i ...interface{})

type Host

type Host struct {
	Address string
}

func (*Host) Load

func (host *Host) Load(path string) ([]*MetricValue, error)

type Logger

type Logger interface {
	Debug(i ...interface{})
}

type MetricConfiguration

type MetricConfiguration struct {
	Unit      string                // TODO: required?
	Filter    func(float64) float64 // Function used to map metric values.
	Aggregate string                // Aggregation of matching metrics
	Rate      string                // Mark metric as rate or downsample.
	Metric    string                // Metric to query for.
	TagFilter string                // Filter on tags (comma separated string with <tag>=<value> pairs.
}

OpenTSDB metric query parameters and configuration for result interpration.

type MetricConfigurations

type MetricConfigurations map[string]*MetricConfiguration

Mapping from the metric identifier to the according configuration used to parse and handle the results.

type MetricValue

type MetricValue struct {
	Key   string    // Metric's key.
	Value float64   // Metric's value.
	Time  time.Time // Timestamp of metric recording.
	Tags  string    // Tags the metric has set.
}

Data type for a metric value.

func (*MetricValue) ExtractTag

func (value *MetricValue) ExtractTag(name string) string

func (*MetricValue) Parse

func (mv *MetricValue) Parse(line string) error

func (*MetricValue) String

func (mv *MetricValue) String() string

type MetricsAggregate

type MetricsAggregate struct {
	Sum float64 // Sum of all values recorded.
	Avg float64 // Average value recorded.
	Min float64 // Minimum value recorded.
	Max float64 // Maximum value recorded.
	// contains filtered or unexported fields
}

Aggregation of metric values.

func (*MetricsAggregate) Diff

func (aggregate *MetricsAggregate) Diff() float64

func (*MetricsAggregate) Duration

func (aggregate *MetricsAggregate) Duration() time.Duration

type MetricsList

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

List of metric values.

func NewMetricsList

func NewMetricsList(tags string) (*MetricsList, error)

Create a new metrics list for the given tags.

func (*MetricsList) Add

func (mvl *MetricsList) Add(mv *MetricValue)

func (*MetricsList) Aggregate

func (mvl *MetricsList) Aggregate() (*MetricsAggregate, error)

Returns aggregate values on the list of data. The computations are cached and returned directly if available. Cache will be invalidated if another value is added.

func (*MetricsList) Data

func (list *MetricsList) Data() []*MetricValue

func (*MetricsList) First

func (mvl *MetricsList) First() *MetricValue

Returns the first metric recorded.

func (*MetricsList) GetTagValue

func (mvl *MetricsList) GetTagValue(tag string) (value string, e error)

Get value of a given tag.

func (*MetricsList) Last

func (mvl *MetricsList) Last() *MetricValue

Returns the last metric recorded.

func (*MetricsList) Len

func (mvl *MetricsList) Len() int

func (*MetricsList) Less

func (mvl *MetricsList) Less(a, b int) bool

func (*MetricsList) Sort

func (mvl *MetricsList) Sort()

func (*MetricsList) Swap

func (mvl *MetricsList) Swap(a, b int)

type MetricsTree

type MetricsTree map[string]tagMap

The metrics tree is a data structure containing metric values sorted after keys and tags.

func GetData

func GetData(attrs *RequestParams) (MetricsTree, error)

Request data from OpenTSDB in ASCII format.

func NewMetricsTree

func NewMetricsTree() MetricsTree

func (MetricsTree) AddMetricValue

func (mt MetricsTree) AddMetricValue(mv *MetricValue) error

Add a new metric value to the metrics tree.

func (MetricsTree) GetMetricsList

func (mt MetricsTree) GetMetricsList(key, tags string) (*MetricsList, error)

func (MetricsTree) GetMetricsListAggregate

func (mt MetricsTree) GetMetricsListAggregate(metric, tag string) (ma *MetricsAggregate, e error)

func (MetricsTree) GetTagsForMetric

func (mt MetricsTree) GetTagsForMetric(metric string) (tags []string, e error)

Get all tags of the given metric that are returned by the according query.

type RequestParams

type RequestParams struct {
	Host    string                 // Host to query.
	Start   string                 // Time point when to start query.
	End     string                 // Time point to end query (optional).
	Metrics []*MetricConfiguration // Configuration of the metrics to request.
}

OpenTSDB request parameters.

Jump to

Keyboard shortcuts

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