opentsdb

package
v0.0.0-...-82de52e Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// WildCard keyword for OpenTSDB filters
	WildCard = "wildcard"

	// LiteralOr keyword for OpenTSDB filters
	LiteralOr = "literal_or"

	// RegExp keyword for OpenTSDB filters
	RegExp = "regexp"
)

Variables

View Source
var OpenTsdbDecoder = schema.NewDecoder()

OpenTsdbDecoder openTSDB schema decoder

Functions

func DecodeDuration

func DecodeDuration(value string, unit string) time.Duration

DecodeDuration convert a ts + unit into Duration

func DecodeRequestParams

func DecodeRequestParams(w http.ResponseWriter, r *http.Request, dst interface{}) error

DecodeRequestParams parse a request into a query structure. This handles the fact that OpenTSDB accepts request parameters both at GET query string parameters and as a POSTed JSON structure

func GetAggregators

func GetAggregators() []string

GetAggregators returns the list of supported aggregators

func ParseOpenTsdbTimeStamp

func ParseOpenTsdbTimeStamp(str string) int64

ParseOpenTsdbTimeStamp parse OpenTSDB times

func WarpResultByteCount

func WarpResultByteCount(response *QueryResponse) int

WarpResultByteCount returns the bytes count of a response

Types

type Filter

type Filter struct {
	Examples    string     `json:"examples"`
	Description string     `json:"description"`
	Translator  Translator `json:"-"`
}

Filter OpenTSDB filters

type FilterSpec

type FilterSpec struct {
	Type       string `json:"type"`
	TagKey     string `json:"tagk"`
	Expression string `json:"filter"`
	GroupBy    bool   `json:"groupBy"`
}

FilterSpec the time series emitted in the results. Note that if no filters are specified, all time series for the given metric will be aggregated into the results.

type IndexResponse

type IndexResponse struct {
	Index int `json:"index"`
}

IndexResponse query struct containing the query index

type OpenTSDB

type OpenTSDB struct {
	ReqCounter  prometheus.Counter
	ErrCounter  prometheus.Counter
	WarnCounter prometheus.Counter
}

OpenTSDB endpoint

func NewOpenTSDB

func NewOpenTSDB() *OpenTSDB

NewOpenTSDB Instantiate an OpenTSDB struct

func (*OpenTSDB) GetReqCounter

func (o *OpenTSDB) GetReqCounter() prometheus.Counter

GetReqCounter satisfies the protocol interface

func (*OpenTSDB) HandleAggregators

func (c *OpenTSDB) HandleAggregators(responseWriter http.ResponseWriter, request *http.Request)

HandleAggregators Handle OpenTSDB aggregators

func (*OpenTSDB) HandleConfigFilters

func (c *OpenTSDB) HandleConfigFilters(responseWriter http.ResponseWriter, request *http.Request)

HandleConfigFilters Filters handling

func (*OpenTSDB) HandleLookup

func (c *OpenTSDB) HandleLookup(responseWriter http.ResponseWriter, request *http.Request)

HandleLookup handle OpenTSDB response nolint: golint

func (*OpenTSDB) HandleQuery

func (o *OpenTSDB) HandleQuery(w http.ResponseWriter, r *http.Request)

HandleQuery Entry point of an OpenTSDB request

func (*OpenTSDB) HandleQueryLast

func (o *OpenTSDB) HandleQueryLast(responseWriter http.ResponseWriter, request *http.Request)

HandleQueryLast is the handler for /api/query/last

func (*OpenTSDB) HandleSuggest

func (c *OpenTSDB) HandleSuggest(w http.ResponseWriter, r *http.Request)

HandleSuggest main /suggest handler nolint: gocyclo

type Query

type Query struct {
	// The name of an aggregation function to use
	Aggregator string `json:"aggregator"`
	// The name of a metric stored in the system
	Metric string `json:"metric"`
	// Whether or not the data should be converted into deltas before returning
	Rate *bool `json:"rate"`
	// Monotonically increasing counter handling options
	RateOptions *RateOptions `json:"rateOptions"`
	// An optional downsampling function to reduce the amount of data returned
	Downsample *string `json:"downsample"`
	// To drill down to specific timeseries or group results by tag
	Tags map[string]string `json:"tags"`
	// Filters the timeseries emitted in the results
	Filters []FilterSpec `json:"filters"`
	// Returns the series that include only the tag keys provided in the filters.
	ExplicitTags bool `json:"explicitTags"`
}

Query an OpenTSDB single query

func (*Query) GetRate

func (q *Query) GetRate() bool

GetRate is it a rate query

func (*Query) Validate

func (q *Query) Validate() error

Validate query

type QueryRequest

type QueryRequest struct {
	// The start time for the query
	Start *TSDBTime `json:"start"`
	// An end time for the query. Default value = time.Now()
	End         *TSDBTime `json:"end"`
	NoTimeRange bool      `json:"-"`
	// One or more sub queries used to select the time series to return
	Queries []*Query `json:"queries"`
	// Whether or not to output data point timestamps in milliseconds or seconds
	MSResolution *bool `json:"msResolution"`
	Delete       bool  `json:"delete"`
}

QueryRequest an OpenTSDB valid request

func (*QueryRequest) Validate

func (handler *QueryRequest) Validate() error

Validate is the implementation of Validate for QueryRequest

type QueryResponse

type QueryResponse struct {
	Metric        string             `json:"metric"`
	Tags          map[string]string  `json:"tags"`
	Query         IndexResponse      `json:"query"`
	AggregateTags []string           `json:"aggregateTags"`
	DPs           map[string]float64 `json:"dps"`
}

QueryResponse an OpenTSDB Query response

type RateOptions

type RateOptions struct {
	// Whether or not the underlying data is a monotonically increasing counter that may roll over
	Counter bool `json:"counter"`
	// A positive integer representing the maximum value for the counter
	CounterMax *int64 `json:"counterMax"`
	// An optional value that, when exceeded, will cause the aggregator to return
	// a 0 instead of the calculated rate
	ResetValue *int64 `json:"resetValue"`
	// Optional: Whether or not to simply drop rolled-over or reset data points.
	DropResets bool `json:"dropResets"`
}

RateOptions monotonically increasing counter handling options

type Response

type Response struct {
	PointsCount int             `json:"pointsCount"`
	Buffer      json.RawMessage `json:"series"`
}

Response OpenTSDB response struct

type SuggestQuery

type SuggestQuery struct {
	Type string `schema:"type" json:"type"` // "metric", "tagk" or "tagv"
	Q    string `schema:"q"    json:"q,omitempty"`
	Max  int    `schema:"max"  json:"max,omitempty"`
}

SuggestQuery is the OpenTSDB suggest query input

type TSDBTime

type TSDBTime struct {
	time.Time
}

TSDBTime is overloading json/schema time parsing to support opentsdb format

func (*TSDBTime) Parse

func (t *TSDBTime) Parse(data string) error

Parse a string representing a date See http://opentsdb.net/docs/build/html/user_guide/query/dates.html

func (*TSDBTime) UnmarshalJSON

func (t *TSDBTime) UnmarshalJSON(b []byte) error

UnmarshalJSON is a Custom json parser

type Translator

type Translator func(string) string

Translator openTSDB translator to WarpScript

type Validatable

type Validatable interface {
	Validate() error
}

Validatable is the interface for the Validate method

Jump to

Keyboard shortcuts

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