common

package
v4.5.2003+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AggregationOverTime = map[AggregateFunction]string{
		MaxOverTime: "max_over_time",
		AvgOverTime: "avg_over_time",
	}

	TimeRange2AggregationOverTime = map[Common.TimeRange_AggregateFunction]AggregateFunction{
		Common.TimeRange_NONE: None,
		Common.TimeRange_MAX:  MaxOverTime,
		Common.TimeRange_AVG:  AvgOverTime,
	}
)
View Source
var (
	DefaultStepTime, _ = time.ParseDuration("30s")
)

Functions

This section is empty.

Types

type AggregateFunction

type AggregateFunction = int

Aggregate function enumerator

const (
	None        AggregateFunction = 0
	MaxOverTime AggregateFunction = 1
	AvgOverTime AggregateFunction = 2
)

Aggregation function definition

type Condition added in v0.9.166

type Condition struct {
	Keys      []string
	Values    []string
	Operators []string
	Types     []DataType
}

type DataType added in v0.9.166

type DataType int

Data type enumerator

const (
	Invalid DataType = iota
	Bool
	Int
	Int8
	Int16
	Int32
	Int64
	Uint
	Uint8
	Uint16
	Uint32
	Uint64
	Float32
	Float64
	String
)

Data type definition

type Function

type Function struct {
	Type              FunctionType
	Fields            []string
	Tags              []string
	Target            string
	RegularExpression string
	Unit              string
	Number            int64
}

type FunctionType

type FunctionType = int

Function type enumerator

const (
	NoneFunction FunctionType = iota

	// Aggregation Function
	FunctionCount  // Returns the number of non-null field values
	FuncDistinct   // Returns the list of unique field values
	FuncIntegral   // Returns the area under the curve for subsequent field values
	FunctionMean   // Returns the arithmetic mean (average) of field values
	FunctionMedian // Returns the middle value from a sorted list of field values
	FunctionMode   // Returns the most frequent value in a list of field values
	FunctionSpread // Returns the difference between the minimum and maximum field values
	FunctionStddev // Returns the standard deviation of field values
	FunctionSum    // Returns the sum of field values

	// Selector function
	FunctionBottom     // Returns the smallest N field values
	FunctionFirst      // Returns the field value with the oldest timestamp
	FunctionLast       // Returns the field value with the most recent timestamp
	FunctionMax        // Returns the greatest field value
	FunctionMin        // Returns the lowest field value
	FunctionPercentile // Returns the Nth percentile field value
	FunctionSample     // Returns a random sample of N field values. SAMPLE() uses reservoir sampling to generate the random points
	FunctionTop        // Returns the greatest N field values

	// Transformation function
	FuncDerivative // Returns the rate of change between subsequent field values
)

type Group added in v0.9.166

type Group struct {
	Columns []string
	Rows    []*Row
}

type Into

type Into struct {
	Database                 string
	RetentionPolicy          string
	Measurement              string
	IsDefaultRetentionPolicy bool
	IsAllMeasurements        bool
}

type Option

type Option func(*Options)

func AggregateOverTimeFunc

func AggregateOverTimeFunc(f AggregateFunction) Option

func EndTime

func EndTime(t *time.Time) Option

func StartTime

func StartTime(t *time.Time) Option

func StepTime

func StepTime(d *time.Duration) Option

func Timeout

func Timeout(t *time.Time) Option

type Options

type Options struct {
	StartTime             *time.Time
	EndTime               *time.Time
	Timeout               *time.Time
	StepTime              *time.Duration
	AggregateOverTimeFunc AggregateFunction
}

func NewDefaultOptions

func NewDefaultOptions() Options

type Order

type Order = int

Order enumerator

const (
	NoneOrder Order = iota
	Asc             // Represent ascending order
	Desc            // Represent descending order
)

Sort order definition

type QueryCondition

type QueryCondition struct {
	StartTime                 *time.Time
	EndTime                   *time.Time
	Timeout                   *time.Time
	StepTime                  *time.Duration
	Function                  *Function
	Into                      *Into
	TimestampOrder            Order
	WhereClause               string
	WhereCondition            []*Condition
	Selects                   []string
	Groups                    []string
	Limit                     int
	AggregateOverTimeFunction AggregateFunction
}

QueryCondition Others query condition

func BuildQueryCondition

func BuildQueryCondition(condition *Common.QueryCondition) QueryCondition

func BuildQueryConditionV1

func BuildQueryConditionV1(condition *ApiCommon.QueryCondition) *QueryCondition

func NewQueryCondition added in v0.9.166

func NewQueryCondition(days, hours, seconds, steps int) *QueryCondition

type Row added in v0.9.166

type Row struct {
	Time   *time.Time
	Values []string
}

Jump to

Keyboard shortcuts

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