types

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: BSD-2-Clause Imports: 15 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWildcardNotAllowed is an eval error returned when a wildcard/glob argument is found where a single series is required.
	ErrWildcardNotAllowed = errors.New("found wildcard where series expected")
	// ErrTooManyArguments is an eval error returned when too many arguments are provided.
	ErrTooManyArguments = errors.New("too many arguments")
)
View Source
var FunctionTypeToStr = map[FunctionType]string{
	AggFunc:         "aggFunc",
	Boolean:         "boolean",
	Date:            "date",
	Float:           "float",
	IntOrInterval:   "intOrInterval",
	Integer:         "integer",
	Interval:        "interval",
	Node:            "node",
	NodeOrTag:       "nodeOrTag",
	SeriesList:      "seriesList",
	SeriesLists:     "seriesLists",
	String:          "string",
	Tag:             "tag",
	Any:             "any",
	AggOrSeriesFunc: "aggOrSeriesFunc",
	IntOrInf:        "intOrInf",
}

FunctionTypeToStr provides a mapping between internal type constants and graphite-friendly string that have a name of a type

Functions

func ConsolidateJSON

func ConsolidateJSON(maxDataPoints int64, results []*MetricData)

ConsolidateJSON consolidates values to maxDataPoints size

func ExtractName added in v0.16.0

func ExtractName(s string) string

ExtractName extracts name out of function list. Only for use in MetrciData name parse, it's has more allowed chard in names, like =

func ExtractNameLoc added in v0.16.0

func ExtractNameLoc(s string) (int, int)

ExtractNameLoc extracts name start:end location out of function list with . Only for use in MetrciData name parse, it's has more allowed chard in names, like =

func ExtractNameTag added in v0.16.0

func ExtractNameTag(s string) string

ExtractNameTag extracts name tag out of function list with . Only for use in MetrciData name parse, it's has more allowed chard in names, like =

func MarshalCSV

func MarshalCSV(results []*MetricData) []byte

MarshalCSV marshals metric data to CSV

func MarshalJSON

func MarshalJSON(results []*MetricData, timestampMultiplier int64, noNullPoints bool) []byte

MarshalJSON marshals metric data to JSON

func MarshalPickle

func MarshalPickle(results []*MetricData) []byte

MarshalPickle marshals metric data to pickle format

func MarshalProtobufV2 added in v0.13.0

func MarshalProtobufV2(results []*MetricData) ([]byte, error)

MarshalProtobufV3 marshals metric data to protobuf

func MarshalProtobufV3 added in v0.13.0

func MarshalProtobufV3(results []*MetricData) ([]byte, error)

MarshalProtobufV3 marshals metric data to protobuf

func MarshalRaw

func MarshalRaw(results []*MetricData) []byte

MarshalRaw marshals metric data to graphite's internal format, called 'raw'

Types

type FunctionDescription

type FunctionDescription struct {
	Description string          `json:"description"`
	Function    string          `json:"function"`
	Group       string          `json:"group"`
	Module      string          `json:"module"`
	Name        string          `json:"name"`
	Params      []FunctionParam `json:"params,omitempty"`

	Proxied bool `json:"proxied"`

	SeriesChange bool `json:"aggregate,omitempty"`       //  function aggregate metrics, for tests and verify results in future
	NameChange   bool `json:"name-change,omitempty"`     // function change name, for tests and verify results in future
	TagsChange   bool `json:"name-tag-change,omitempty"` //  function change name tag, for tests and verify results in future
	ValuesChange bool `json:"values-change,omitempty"`   //  function change values, for tests and verify results in future
}

FunctionDescription contains full function description.

type FunctionParam

type FunctionParam struct {
	Name        string        `json:"name"`
	Multiple    bool          `json:"multiple,omitempty"`
	Required    bool          `json:"required,omitempty"`
	Type        FunctionType  `json:"type,omitempty"`
	Options     []Suggestion  `json:"options,omitempty"`
	Suggestions []*Suggestion `json:"suggestions,omitempty"`
	Default     *Suggestion   `json:"default,omitempty"`
}

FunctionParam contains list of all available parameters of function

type FunctionType

type FunctionType int

FunctionType is a special type to handle parameter type in function description

const (
	// AggFunc is a constant for AggregationFunction type
	AggFunc FunctionType = iota
	// Boolean is a constant for Boolean type
	Boolean
	// Date is a constant for Date type
	Date
	// Float is a constant for Float type
	Float
	// IntOrInterval is a constant for Interval-Or-Integer type
	IntOrInterval
	// Integer is a constant for Integer type
	Integer
	// Interval is a constant for Interval type
	Interval
	// Node is a constant for Node type
	Node
	// NodeOrTag is a constant for Node-Or-Tag type
	NodeOrTag
	// SeriesList is a constant for SeriesList type
	SeriesList
	// SeriesLists is a constant for SeriesLists type
	SeriesLists
	// String is a constant for String type
	String
	// Tag is a constant for Tag type
	Tag
	// Any is a constant for `Any` type
	Any
	// AggOrSeriesFunc is a constant for AggregationFunction or SeriesList
	AggOrSeriesFunc
	// IntOrInf is a constant for Integer that can be infinity
	IntOrInf
)

func (FunctionType) MarshalJSON

func (t FunctionType) MarshalJSON() ([]byte, error)

MarshalJSON marshals metric data to JSON

func (*FunctionType) UnmarshalJSON

func (t *FunctionType) UnmarshalJSON(d []byte) error

type GraphOptions

type GraphOptions struct {
}

type MetricData

type MetricData struct {
	pb.FetchResponse

	GraphOptions

	ValuesPerPoint int

	Tags              map[string]string
	AggregateFunction func([]float64) float64 `json:"-"`
	// contains filtered or unexported fields
}

MetricData contains necessary data to represent parsed metric (ready to be send out or drawn)

func CopyMetricDataSlice added in v0.14.1

func CopyMetricDataSlice(args []*MetricData) (newData []*MetricData)

CopyMetricDataSlice returns the slice of metrics that should be changed later. It allows to avoid a changing of source data, e.g. by AlignMetrics

func CopyMetricDataSliceLink(args []*MetricData) (newData []*MetricData)

CopyMetricDataSliceLink returns the copies slice of metrics, Values not copied and link from parent.

func CopyMetricDataSliceWithName added in v0.16.0

func CopyMetricDataSliceWithName(args []*MetricData, name string) (newData []*MetricData)

CopyMetricDataSliceWithName returns the copies slice of metrics with name overwrite, Values not copied and link from parent. Tags will be reset

func CopyMetricDataSliceWithTags added in v0.16.0

func CopyMetricDataSliceWithTags(args []*MetricData, name string, tags map[string]string) (newData []*MetricData)

CopyMetricDataSliceWithTags returns the copies slice of metrics with name overwrite, Values not copied and link from parent.

func MakeMetricData

func MakeMetricData(name string, values []float64, step, start int64) *MetricData

MakeMetricData creates new metrics data with given metric timeseries

func (*MetricData) AggregateValues

func (r *MetricData) AggregateValues()

AggregateValues aggregates values

func (*MetricData) AggregatedTimeStep

func (r *MetricData) AggregatedTimeStep() int64

AggregatedTimeStep aggregates time step

func (*MetricData) AggregatedValues

func (r *MetricData) AggregatedValues() []float64

AggregatedValues aggregates values (with cache)

func (*MetricData) AppendStopTime added in v0.16.0

func (r *MetricData) AppendStopTime(step int64) *MetricData

AppendStopTime append to StopTime for simulate broken time series

func (*MetricData) Copy added in v0.14.1

func (r *MetricData) Copy(includeValues bool) *MetricData

Copy returns the copy of r. If includeValues set to true, it copies values as well.

func (r *MetricData) CopyLink() *MetricData

CopyLink returns the copy of MetricData, Values not copied and link from parent. Tags map are copied

func (*MetricData) CopyLinkTags added in v0.16.0

func (r *MetricData) CopyLinkTags() *MetricData

CopyLinkTags returns the copy of MetricData, Values not copied and link from parent. Tags map set by rereference without copy (so, DON'T change them for prevent naming bugs)

func (*MetricData) CopyName added in v0.16.0

func (r *MetricData) CopyName(name string) *MetricData

CopyName returns the copy of MetricData, Values not copied and link from parent. If name set, Name and Name tag changed

func (*MetricData) CopyNameArg added in v0.16.0

func (r *MetricData) CopyNameArg(name, defaultName string, defaultTags map[string]string, extractTags bool) *MetricData

CopyNameArg returns the copy of MetricData, Values not copied and link from parent. Name is changed, tags extracted from seriesByTag args, if extractTags is true For use in functions like aggregate

func (*MetricData) CopyNameWithDefault added in v0.16.0

func (r *MetricData) CopyNameWithDefault(name, defaultName string) *MetricData

CopyNameWithDefault returns the copy of MetricData, Values not copied and link from parent. Name is changed, Tags will be reset. If Name tag not set, it will be set with default value. Use this function in aggregate function (like sumSeries)

func (*MetricData) CopyNameWithVal added in v0.16.0

func (r *MetricData) CopyNameWithVal(name string) *MetricData

CopyName returns the copy of MetricData, Values not copied and link from parent. If name set, Name and Name tag changed, Tags wil be reset

func (*MetricData) CopyTag added in v0.16.0

func (r *MetricData) CopyTag(name string, tags map[string]string) *MetricData

CopyTag returns the copy of MetricData, Values not copied and link from parent. If name set, Name and Name tag changed, Tags will be reset. WARNING: can provide inconsistence beetween name and tags, if incorectly used

func (*MetricData) FixNameTag added in v0.16.0

func (r *MetricData) FixNameTag() *MetricData

FixNameTag for safe name tag for future use without metric.ExtractMetric

func (*MetricData) FixStopTime added in v0.16.0

func (r *MetricData) FixStopTime() *MetricData

FixStopTime fix broken StopTime (less than need for values)

func (*MetricData) GetAggregateFunction added in v0.14.1

func (r *MetricData) GetAggregateFunction() func([]float64) float64

GetAggregateFunction returns MetricData.AggregateFunction and set it, if it's not yet

func (*MetricData) RecalcStopTime added in v0.16.0

func (r *MetricData) RecalcStopTime() *MetricData

RecalcStopTime recalc StopTime with StartTime and Values length

func (*MetricData) SetConsolidationFunc added in v0.16.0

func (r *MetricData) SetConsolidationFunc(f string) *MetricData

SetConsolidationFunc set ConsolidationFunc

func (*MetricData) SetNameTag added in v0.16.0

func (r *MetricData) SetNameTag(name string) *MetricData

SetNameTag set name tag

func (*MetricData) SetTag added in v0.16.0

func (r *MetricData) SetTag(key, value string) *MetricData

SetTag allow to set custom tag (for tests)

func (*MetricData) SetTags added in v0.16.0

func (r *MetricData) SetTags(tags map[string]string) *MetricData

SetTag allow to set tags

func (*MetricData) SetValuesPerPoint

func (r *MetricData) SetValuesPerPoint(v int)

SetValuesPerPoint sets value per point coefficient.

func (*MetricData) SetXFilesFactor added in v0.16.0

func (r *MetricData) SetXFilesFactor(x float32) *MetricData

SetXFilesFactor set XFilesFactor

type MetricHeap

type MetricHeap []MetricHeapElement

func (MetricHeap) Len

func (m MetricHeap) Len() int

func (MetricHeap) Less

func (m MetricHeap) Less(i, j int) bool

func (*MetricHeap) Pop

func (m *MetricHeap) Pop() interface{}

Pop pops out data from MetricHeap

func (*MetricHeap) Push

func (m *MetricHeap) Push(x interface{})

Push pushes data to MetricHeap

func (MetricHeap) Swap

func (m MetricHeap) Swap(i, j int)

type MetricHeapElement

type MetricHeapElement struct {
	Idx int
	Val float64
}

type Option added in v0.15.3

type Option struct {
	Type  SuggestionTypes
	Value interface{}
}

type Suggestion

type Suggestion struct {
	Type  SuggestionTypes
	Value interface{}
}

func NewSuggestion

func NewSuggestion(arg interface{}) *Suggestion

func NewSuggestions

func NewSuggestions(vaArgs ...interface{}) []*Suggestion

func StringsToSuggestionList added in v0.15.3

func StringsToSuggestionList(in []string) []Suggestion

func (Suggestion) MarshalJSON

func (t Suggestion) MarshalJSON() ([]byte, error)

MarshalJSON marshals metric data to JSON

func (*Suggestion) UnmarshalJSON

func (t *Suggestion) UnmarshalJSON(d []byte) error

type SuggestionTypes

type SuggestionTypes int
const (
	SInt SuggestionTypes = iota
	SInt32
	SInt64
	SUint
	SUint32
	SUint64
	SFloat64
	SString
	SBool
	SNone
)

type Windowed

type Windowed struct {
	Data []float64
	// contains filtered or unexported fields
}

Windowed is a struct to compute simple windowed stats

func (*Windowed) Count added in v0.16.0

func (w *Windowed) Count() float64

Count returns number of non-NaN points

func (*Windowed) Diff added in v0.16.0

func (w *Windowed) Diff() float64

Diff subtracts series 2 through n from series 1

func (*Windowed) IsNonNull added in v0.16.1

func (w *Windowed) IsNonNull() bool

IsNonNull checks if the window's data contains only NaN values This is to prevent returning -Inf when the window's data contains only NaN values

func (*Windowed) Last added in v0.16.0

func (w *Windowed) Last() float64

Last returns the last data point

func (*Windowed) Len

func (w *Windowed) Len() int

Len returns current len of data

func (*Windowed) Max

func (w *Windowed) Max() float64

Max returns max(values)

func (*Windowed) Mean

func (w *Windowed) Mean() float64

Mean returns mean value of data

func (*Windowed) MeanZero added in v0.16.0

func (w *Windowed) MeanZero() float64

MeanZero returns mean value of data, with NaN values replaced with 0

func (*Windowed) Median added in v0.16.0

func (w *Windowed) Median() float64

func (*Windowed) Min

func (w *Windowed) Min() float64

Min returns min(values)

func (*Windowed) Multiply added in v0.16.0

func (w *Windowed) Multiply() float64

func (*Windowed) Push

func (w *Windowed) Push(n float64)

Push pushes data

func (*Windowed) Range added in v0.16.0

func (w *Windowed) Range() float64

func (*Windowed) Reset added in v0.16.0

func (w *Windowed) Reset()

func (*Windowed) Stdev

func (w *Windowed) Stdev() float64

Stdev computes standard deviation of data

func (*Windowed) Sum

func (w *Windowed) Sum() float64

Sum returns sum of data

func (*Windowed) SumSQ

func (w *Windowed) SumSQ() float64

SumSQ returns sum of squares

Jump to

Keyboard shortcuts

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