tsdb

package
v0.0.0-...-34a2968 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EpochPrecisionToMs

func EpochPrecisionToMs(value float64) float64

EpochPrecisionToMs converts epoch precision to millisecond, if needed. Only seconds to milliseconds supported right now

func FormatDuration

func FormatDuration(inter time.Duration) string

FormatDuration converts a duration into the kbn format e.g. 1m 2h or 3d

func GetIntervalFrom

func GetIntervalFrom(dsInfo *models.DataSource, queryModel *simplejson.Json, defaultInterval time.Duration) (time.Duration, error)

func NewIntervalCalculator

func NewIntervalCalculator(opt *IntervalOptions) *intervalCalculator

func RegisterTsdbQueryEndpoint

func RegisterTsdbQueryEndpoint(pluginId string, fn GetTsdbQueryEndpointFn)

func SeriesToFrame

func SeriesToFrame(series *TimeSeries) (*data.Frame, error)

SeriesToFrame converts a TimeSeries to a sdk Frame

Types

type DataFrames

type DataFrames interface {
	// Encoded encodes Frames into a slice of []byte.
	// If an error occurs [][]byte will be nil.
	// The encoded result, if any, will be cached and returned next time Encoded is called.
	Encoded() ([][]byte, error)

	// Decoded decodes a slice of Arrow encoded frames to data.Frames ([]*data.Frame).
	// If an error occurs Frames will be nil.
	// The decoded result, if any, will be cached and returned next time Decoded is called.
	Decoded() (data.Frames, error)
}

DataFrames interface for retrieving encoded and decoded data frames.

See NewDecodedDataFrames and NewEncodedDataFrames for more information.

func NewDecodedDataFrames

func NewDecodedDataFrames(decodedFrames data.Frames) DataFrames

NewDecodedDataFrames instantiates DataFrames from decoded frames.

This should be the primary function for creating DataFrames if you're implementing a plugin. In a Grafana alerting scenario it needs to operate on decoded frames, which is why this function is preferrable. When encoded data frames are needed, e.g. returned from Grafana HTTP API, it will happen automatically when MarshalJSON() is called.

func NewEncodedDataFrames

func NewEncodedDataFrames(encodedFrames [][]byte) DataFrames

NewEncodedDataFrames instantiates DataFrames from encoded frames.

This one is primarily used for creating DataFrames when receiving encoded data frames from an external plugin or similar. This may allow the encoded data frames to be returned to Grafana UI without any additional decoding/encoding required. In Grafana alerting scenario it needs to operate on decoded data frames why encoded frames needs to be decoded before usage.

type GetTsdbQueryEndpointFn

type GetTsdbQueryEndpointFn func(dsInfo *models.DataSource) (TsdbQueryEndpoint, error)

type HandleRequestFunc

type HandleRequestFunc func(ctx context.Context, dsInfo *models.DataSource, req *TsdbQuery) (*Response, error)

type Interval

type Interval struct {
	Text  string
	Value time.Duration
}

func (*Interval) Milliseconds

func (i *Interval) Milliseconds() int64

type IntervalCalculator

type IntervalCalculator interface {
	Calculate(timeRange *TimeRange, minInterval time.Duration) Interval
}

type IntervalOptions

type IntervalOptions struct {
	MinInterval time.Duration
}

type Query

type Query struct {
	RefId         string
	Model         *simplejson.Json
	DataSource    *models.DataSource
	MaxDataPoints int64
	IntervalMs    int64
	QueryType     string
}

type QueryResult

type QueryResult struct {
	Error       error            `json:"-"`
	ErrorString string           `json:"error,omitempty"`
	RefId       string           `json:"refId"`
	Meta        *simplejson.Json `json:"meta,omitempty"`
	Series      TimeSeriesSlice  `json:"series"`
	Tables      []*Table         `json:"tables"`
	Dataframes  DataFrames       `json:"dataframes"`
}

func NewQueryResult

func NewQueryResult() *QueryResult

type Response

type Response struct {
	Results map[string]*QueryResult `json:"results"`
	Message string                  `json:"message,omitempty"`
}

func HandleRequest

func HandleRequest(ctx context.Context, dsInfo *models.DataSource, req *TsdbQuery) (*Response, error)

type RowValues

type RowValues []interface{}

type Table

type Table struct {
	Columns []TableColumn `json:"columns"`
	Rows    []RowValues   `json:"rows"`
}

type TableColumn

type TableColumn struct {
	Text string `json:"text"`
}

type TimePoint

type TimePoint [2]null.Float

func NewTimePoint

func NewTimePoint(value null.Float, timestamp float64) TimePoint

type TimeRange

type TimeRange struct {
	From string
	To   string
	// contains filtered or unexported fields
}

func NewFakeTimeRange

func NewFakeTimeRange(from, to string, now time.Time) *TimeRange

func NewTimeRange

func NewTimeRange(from, to string) *TimeRange

func (*TimeRange) GetFromAsMsEpoch

func (tr *TimeRange) GetFromAsMsEpoch() int64

func (*TimeRange) GetFromAsSecondsEpoch

func (tr *TimeRange) GetFromAsSecondsEpoch() int64

func (*TimeRange) GetFromAsTimeUTC

func (tr *TimeRange) GetFromAsTimeUTC() time.Time

func (*TimeRange) GetToAsMsEpoch

func (tr *TimeRange) GetToAsMsEpoch() int64

func (*TimeRange) GetToAsSecondsEpoch

func (tr *TimeRange) GetToAsSecondsEpoch() int64

func (*TimeRange) GetToAsTimeUTC

func (tr *TimeRange) GetToAsTimeUTC() time.Time

func (*TimeRange) MustGetFrom

func (tr *TimeRange) MustGetFrom() time.Time

func (*TimeRange) MustGetTo

func (tr *TimeRange) MustGetTo() time.Time

func (*TimeRange) ParseFrom

func (tr *TimeRange) ParseFrom() (time.Time, error)

func (*TimeRange) ParseFromWithLocation

func (tr *TimeRange) ParseFromWithLocation(location *time.Location) (time.Time, error)

func (*TimeRange) ParseTo

func (tr *TimeRange) ParseTo() (time.Time, error)

func (*TimeRange) ParseToWithLocation

func (tr *TimeRange) ParseToWithLocation(location *time.Location) (time.Time, error)

type TimeSeries

type TimeSeries struct {
	Name   string            `json:"name"`
	Points TimeSeriesPoints  `json:"points"`
	Tags   map[string]string `json:"tags,omitempty"`
}

func NewTimeSeries

func NewTimeSeries(name string, points TimeSeriesPoints) *TimeSeries

type TimeSeriesPoints

type TimeSeriesPoints []TimePoint

func NewTimeSeriesPointsFromArgs

func NewTimeSeriesPointsFromArgs(values ...float64) TimeSeriesPoints

type TimeSeriesSlice

type TimeSeriesSlice []*TimeSeries

func FrameToSeriesSlice

func FrameToSeriesSlice(frame *data.Frame) (TimeSeriesSlice, error)

FrameToSeriesSlice converts a frame that is a valid time series as per data.TimeSeriesSchema() to a TimeSeriesSlice.

type TsdbQuery

type TsdbQuery struct {
	TimeRange *TimeRange
	Queries   []*Query
	Headers   map[string]string
	Debug     bool
	User      *models.SignedInUser
}

TsdbQuery contains all information about a query request.

type TsdbQueryEndpoint

type TsdbQueryEndpoint interface {
	Query(ctx context.Context, ds *models.DataSource, query *TsdbQuery) (*Response, error)
}

Directories

Path Synopsis
mock_stsiface
Package mock_stsiface is a generated GoMock package.
Package mock_stsiface is a generated GoMock package.

Jump to

Keyboard shortcuts

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