series

package
v0.0.0-...-202a999 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ConsolidateAverage represents an average consolidation type.
	ConsolidateAverage
	// ConsolidateFirst represents a first value consolidation type.
	ConsolidateFirst
	// ConsolidateLast represents a last value consolidation type.
	ConsolidateLast
	// ConsolidateMax represents a maximal value consolidation type.
	ConsolidateMax
	// ConsolidateMin represents a minimal value consolidation type.
	ConsolidateMin
	// ConsolidateSum represents a sum consolidation type.
	ConsolidateSum
)
View Source
const (
	// OperatorNone represents a null operation type.
	OperatorNone = iota
	// OperatorAverage represents an average operation type.
	OperatorAverage
	// OperatorSum represents a sum operation type.
	OperatorSum
)
View Source
const (
	// DefaultSample represents the default sample value.
	DefaultSample = 400
)

Variables

View Source
var (
	// ErrInvalidSample represents an invalid series sample value error.
	ErrInvalidSample = errors.New("invalid sample value")
	// ErrEmptySeries represents a empty series list error.
	ErrEmptySeries = errors.New("no series provided")
	// ErrUnnormalizedSeries represents an unnormalized series list error.
	ErrUnnormalizedSeries = errors.New("unnormalized series")
)

Functions

This section is empty.

Types

type Point

type Point struct {
	Time  time.Time `json:"time"`
	Value Value     `json:"value"`
	// contains filtered or unexported fields
}

Point represents a time series point instance.

func (Point) MarshalJSON

func (point Point) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*Point) UnmarshalJSON

func (point *Point) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Query

type Query struct {
	StartTime time.Time
	EndTime   time.Time
	Sample    int
	Metrics   []*catalog.Metric
}

Query represents a time series point query instance.

type Request

type Request struct {
	StartTime  time.Time      `json:"start_time,omitempty"`
	EndTime    time.Time      `json:"end_time,omitempty"`
	Time       time.Time      `json:"time,omitempty"`
	Range      string         `json:"range,omitempty"`
	Sample     int            `json:"sample"`
	ID         string         `json:"id"`
	Graph      *storage.Graph `json:"graph"`
	Attributes maputil.Map    `json:"attributes,omitempty"`
	Normalize  bool           `json:"normalize"`
}

Request represents a point request instance.

type Response

type Response struct {
	Start   string                 `json:"start"`
	End     string                 `json:"end"`
	Series  []ResponseSeries       `json:"series"`
	Options map[string]interface{} `json:"options"`
}

Response represents a point response instance.

type ResponseSeries

type ResponseSeries struct {
	Series
	Name    string                 `json:"name"`
	Options map[string]interface{} `json:"options"`
}

ResponseSeries represents a point response series instance.

type Series

type Series struct {
	Points  []Point          `json:"points"`
	Summary map[string]Value `json:"summary"`
}

Series represents a time series instance.

func Average

func Average(series []Series) (Series, error)

Average returns a new series averaging each datapoints.

func Normalize

func Normalize(series []Series, startTime, endTime time.Time, sample int, consolidation int) ([]Series, error)

Normalize aligns multiple point series on a common time step, consolidates points samples if necessary.

func Sum

func Sum(series []Series) (Series, error)

Sum returns a new series summing each datapoints.

func (*Series) Percentiles

func (s *Series) Percentiles(values []float64)

Percentiles calculates the percentile values for a time series.

func (*Series) Scale

func (s *Series) Scale(factor Value)

Scale applies a factor on a series of points.

func (*Series) Summarize

func (s *Series) Summarize(percentiles []float64)

Summarize calculates the min/max/average/last and percentile values for a time series.

func (*Series) ZeroNulls

func (s *Series) ZeroNulls()

ZeroNulls replaces all null point values by zero.

type Value

type Value float64

Value represents a time series point value.

func (Value) IsNaN

func (value Value) IsNaN() bool

IsNaN reports whether the Value is an IEEE 754 'not-a-number' value.

func (Value) MarshalJSON

func (value Value) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

Jump to

Keyboard shortcuts

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