opentsdb

package
v1.59.0-cluster Latest Latest
Warning

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

Go to latest
Published: May 1, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Addr string
	// The meta query limit for series returned
	Limit      int
	Retentions []Retention
	Filters    []string
	Normalize  bool
	HardTS     int64
}

Client object holds general config about how queries should be performed

func NewClient

func NewClient(cfg Config) (*Client, error)

NewClient creates and returns OpenTSDB client configured with passed Config

func (Client) FindMetrics

func (c Client) FindMetrics(q string) ([]string, error)

FindMetrics discovers all metrics that OpenTSDB knows about (given a filter) e.g. /api/suggest?type=metrics&q=system&max=100000

func (Client) FindSeries

func (c Client) FindSeries(metric string) ([]Meta, error)

FindSeries discovers all series associated with a metric e.g. /api/search/lookup?m=system.load5&limit=1000000

func (Client) GetData

func (c Client) GetData(series Meta, rt RetentionMeta, start int64, end int64) (Metric, error)

GetData actually retrieves data for a series at a specified time range

type Config

type Config struct {
	Addr       string
	Limit      int
	Offset     int64
	HardTS     int64
	Retentions []string
	Filters    []string
	Normalize  bool
	MsecsTime  bool
}

Config contains fields required for Client configuration

type Expression

type Expression struct {
	Time    timeObj     `json:"time"`
	Filters []filterObj `json:"filters"`
	Metrics []metricObj `json:"metrics"`
	// this just needs to be an empty object, so the value doesn't matter
	Expressions []int       `json:"expressions"`
	Outputs     []outputObj `json:"outputs"`
}

Expression objects format our data queries

All of the following structs are to build a OpenTSDB expression object

type ExpressionOutput

type ExpressionOutput struct {
	Outputs []qoObj     `json:"outputs"`
	Query   interface{} `json:"query"`
}

ExpressionOutput contains results from actual data queries

type Meta

type Meta struct {
	//tsuid  string
	Metric string            `json:"metric"`
	Tags   map[string]string `json:"tags"`
}

Meta A meta object about a metric only contain the tags/etc. and no data

type MetaResults

type MetaResults struct {
	Type    string `json:"type"`
	Results []Meta `json:"results"`
}

MetaResults contains return data from search series lookup queries

type Metric

type Metric struct {
	Metric     string
	Tags       map[string]string
	Timestamps []int64
	Values     []float64
}

Metric holds the time series data

type Retention

type Retention struct {
	/*
		OpenTSDB has two levels of aggregation,
		First, we aggregate any un-mentioned tags into the last result
		Second, we aggregate into buckets over time
		To simulate this with config, we have
		FirstOrder (e.g. sum/avg/max/etc.)
		SecondOrder (e.g. sum/avg/max/etc.)
		AggTime	(e.g. 1m/10m/1d/etc.)
		This will build into m=<FirstOrder>:<AggTime>-<SecondOrder>-none:
		Or an example: m=sum:1m-avg-none
	*/
	FirstOrder  string
	SecondOrder string
	AggTime     string
	// The actual ranges will will attempt to query (as offsets from now)
	QueryRanges []TimeRange
}

Retention objects contain meta data about what to query for our run

type RetentionMeta

type RetentionMeta struct {
	FirstOrder  string
	SecondOrder string
	AggTime     string
}

RetentionMeta objects exist to pass smaller subsets (only one retention range) of a full Retention object around

type TimeRange

type TimeRange struct {
	Start int64
	End   int64
}

TimeRange contains data about time ranges to query

Jump to

Keyboard shortcuts

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