Documentation ¶
Index ¶
- func ConvertSqlTimeColumnToEpochMs(values RowValues, timeIndex int)
- func ConvertSqlValueColumnToFloat(columnName string, columnValue interface{}) (null.Float, error)
- func EpochPrecisionToMs(value float64) float64
- func GetIntervalFrom(dsInfo *models.DataSource, queryModel *simplejson.Json, ...) (time.Duration, error)
- func NewIntervalCalculator(opt *IntervalOptions) *intervalCalculator
- func RegisterTsdbQueryEndpoint(pluginId string, fn GetTsdbQueryEndpointFn)
- type DefaultSqlEngine
- type GetTsdbQueryEndpointFn
- type HandleRequestFunc
- type Interval
- type IntervalCalculator
- type IntervalOptions
- type Query
- type QueryResult
- type Response
- type RowValues
- type SqlEngine
- type SqlMacroEngine
- type Table
- type TableColumn
- type TimePoint
- type TimeRange
- func (tr *TimeRange) GetFromAsMsEpoch() int64
- func (tr *TimeRange) GetFromAsSecondsEpoch() int64
- func (tr *TimeRange) GetFromAsTimeUTC() time.Time
- func (tr *TimeRange) GetToAsMsEpoch() int64
- func (tr *TimeRange) GetToAsSecondsEpoch() int64
- func (tr *TimeRange) GetToAsTimeUTC() time.Time
- func (tr *TimeRange) MustGetFrom() time.Time
- func (tr *TimeRange) MustGetTo() time.Time
- func (tr *TimeRange) ParseFrom() (time.Time, error)
- func (tr *TimeRange) ParseTo() (time.Time, error)
- type TimeSeries
- type TimeSeriesPoints
- type TimeSeriesSlice
- type TsdbQuery
- type TsdbQueryEndpoint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertSqlTimeColumnToEpochMs ¶ added in v5.1.0
ConvertSqlTimeColumnToEpochMs converts column named time to unix timestamp in milliseconds to make native datetime types and epoch dates work in annotation and table queries.
func ConvertSqlValueColumnToFloat ¶ added in v5.1.0
ConvertSqlValueColumnToFloat converts timeseries value column to float.
func EpochPrecisionToMs ¶ added in v5.1.0
EpochPrecisionToMs converts epoch precision to millisecond, if needed. Only seconds to milliseconds supported right now
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)
Types ¶
type DefaultSqlEngine ¶
type DefaultSqlEngine struct { MacroEngine SqlMacroEngine XormEngine *xorm.Engine }
func (*DefaultSqlEngine) InitEngine ¶
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 ¶
func (e *DefaultSqlEngine) Query( ctx context.Context, dsInfo *models.DataSource, tsdbQuery *TsdbQuery, transformToTimeSeries func(query *Query, rows *core.Rows, result *QueryResult, tsdbQuery *TsdbQuery) error, transformToTable func(query *Query, rows *core.Rows, result *QueryResult, tsdbQuery *TsdbQuery) 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 ¶
type GetTsdbQueryEndpointFn func(dsInfo *models.DataSource) (TsdbQueryEndpoint, error)
type HandleRequestFunc ¶
type IntervalCalculator ¶
type IntervalOptions ¶
type Query ¶
type Query struct { RefId string Model *simplejson.Json DataSource *models.DataSource 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 ¶
type SqlEngine ¶
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, tsdbQuery *TsdbQuery) error, transformToTable func(query *Query, rows *core.Rows, result *QueryResult, tsdbQuery *TsdbQuery) error, ) (*Response, error) }
SqlEngine is a wrapper class around xorm for relational database data sources.
type SqlMacroEngine ¶
type SqlMacroEngine interface {
Interpolate(query *Query, timeRange *TimeRange, sql string) (string, error)
}
SqlMacroEngine interpolates macros into sql. It takes in the Query to have access to query context and timeRange to be able to generate queries that use from and to.
type Table ¶
type Table struct { Columns []TableColumn `json:"columns"` Rows []RowValues `json:"rows"` }
type TableColumn ¶
type TableColumn struct {
Text string `json:"text"`
}
type TimeRange ¶
func NewFakeTimeRange ¶ added in v5.1.0
func NewTimeRange ¶
func (*TimeRange) GetFromAsMsEpoch ¶
func (*TimeRange) GetFromAsSecondsEpoch ¶ added in v5.1.0
func (*TimeRange) GetFromAsTimeUTC ¶ added in v5.1.0
func (*TimeRange) GetToAsMsEpoch ¶
func (*TimeRange) GetToAsSecondsEpoch ¶ added in v5.1.0
func (*TimeRange) GetToAsTimeUTC ¶ added in v5.1.0
func (*TimeRange) MustGetFrom ¶
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