tsdb

package
v4.6.5 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIntervalFrom added in v4.6.2

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

func NewIntervalCalculator added in v4.6.2

func NewIntervalCalculator(opt *IntervalOptions) *intervalCalculator

func RegisterTsdbQueryEndpoint added in v4.6.0

func RegisterTsdbQueryEndpoint(pluginId string, fn GetTsdbQueryEndpointFn)

Types

type DefaultSqlEngine added in v4.6.0

type DefaultSqlEngine struct {
	MacroEngine SqlMacroEngine
	XormEngine  *xorm.Engine
}

func (*DefaultSqlEngine) InitEngine added in v4.6.0

func (e *DefaultSqlEngine) InitEngine(driverName string, dsInfo *models.DataSource, cnnstr string) error

InitEngine creates the db connection and inits the xorm engine or loads it from the engine cache

func (*DefaultSqlEngine) Query added in v4.6.0

func (e *DefaultSqlEngine) Query(
	ctx context.Context,
	dsInfo *models.DataSource,
	tsdbQuery *TsdbQuery,
	transformToTimeSeries func(query *Query, rows *core.Rows, result *QueryResult) error,
	transformToTable func(query *Query, rows *core.Rows, result *QueryResult) error,
) (*Response, error)

Query is a default implementation of the Query method for an SQL data source. The caller of this function must implement transformToTimeSeries and transformToTable and pass them in as parameters.

type GetTsdbQueryEndpointFn added in v4.6.0

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 added in v4.2.0

type Interval struct {
	Text  string
	Value time.Duration
}

type IntervalCalculator added in v4.6.2

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

type IntervalOptions added in v4.6.2

type IntervalOptions struct {
	MinInterval time.Duration
}

type Query

type Query struct {
	RefId         string
	Model         *simplejson.Json
	Depends       []string
	DataSource    *models.DataSource
	Results       []*TimeSeries
	MaxDataPoints int64
	IntervalMs    int64
}

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"`
}

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 added in v4.3.0

type RowValues []interface{}

type SqlEngine added in v4.6.0

type SqlEngine interface {
	InitEngine(driverName string, dsInfo *models.DataSource, cnnstr string) error
	Query(
		ctx context.Context,
		ds *models.DataSource,
		query *TsdbQuery,
		transformToTimeSeries func(query *Query, rows *core.Rows, result *QueryResult) error,
		transformToTable func(query *Query, rows *core.Rows, result *QueryResult) error,
	) (*Response, error)
}

SqlEngine is a wrapper class around xorm for relational database data sources.

type SqlMacroEngine added in v4.6.0

type SqlMacroEngine interface {
	Interpolate(timeRange *TimeRange, sql string) (string, error)
}

SqlMacroEngine interpolates macros into sql. It takes in the timeRange to be able to generate queries that use from and to.

type Table added in v4.3.0

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

type TableColumn added in v4.3.0

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
	Now  time.Time
}

func NewTimeRange

func NewTimeRange(from, to string) *TimeRange

func (*TimeRange) GetFromAsMsEpoch

func (tr *TimeRange) GetFromAsMsEpoch() int64

func (*TimeRange) GetToAsMsEpoch

func (tr *TimeRange) GetToAsMsEpoch() int64

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) ParseTo

func (tr *TimeRange) ParseTo() (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

type TsdbQuery added in v4.6.0

type TsdbQuery struct {
	TimeRange *TimeRange
	Queries   []*Query
}

type TsdbQueryEndpoint added in v4.6.0

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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