tsdb

package
v0.3.9-5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: Apache-2.0 Imports: 12 Imported by: 7

Documentation

Index

Constants

View Source
const (
	ErrorNotFoundExecutorDataSource = errors.Error("Not find executor for data source")
)

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 *DataSource, queryModel *Query, defaultInterval time.Duration) (time.Duration, error)

func NewIntervalCalculator

func NewIntervalCalculator(opt *IntervalOptions) *intervalCalculator

func RegisterTsdbQueryEndpoint

func RegisterTsdbQueryEndpoint(dataSourceType string, fn GetTsdbQueryEndpointFn)

Types

type DataSource

type DataSource struct {
	Id                string
	Name              string
	Type              string
	Url               string
	User              string
	Password          string
	Database          string
	BasicAuth         bool
	BasicAuthUser     string
	BasicAuthPassword string
	TimeInterval      string
	Updated           time.Time
}

func (*DataSource) GetHttpClient

func (ds *DataSource) GetHttpClient() (*http.Client, error)

func (*DataSource) GetHttpTransport

func (ds *DataSource) GetHttpTransport() (*dataSourceTransport, error)

func (*DataSource) GetTLSConfig

func (ds *DataSource) GetTLSConfig() (*tls.Config, error)

type GetTsdbQueryEndpointFn

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

type HandleRequestFunc

type HandleRequestFunc func(ctx context.Context, dsInfo *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
	api.MetricQuery
	DataSource    DataSource
	MaxDataPoints int64
	IntervalMs    int64
}

type QueryResult

type QueryResult struct {
	Error       error           `json:"-"`
	ErrorString string          `json:"error,omitempty"`
	RefId       string          `json:"ref_id"`
	Meta        QueryResultMeta `json:"meta"`
	Series      TimeSeriesSlice `json:"series"`
	Tables      []*Table        `json:"tables"`
	Dataframes  [][]byte        `json:"dataframes"`
}

func NewQueryResult

func NewQueryResult() *QueryResult

type QueryResultMeta

type QueryResultMeta struct {
	RawQuery string `json:"raw_query"`
}

type Response

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

func HandleRequest

func HandleRequest(ctx context.Context, dsInfo *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 []interface{}

func NewTimePoint

func NewTimePoint(value *float64, timestamp float64) TimePoint

func NewTimePointByVal

func NewTimePointByVal(value float64, timestamp float64) TimePoint

func (TimePoint) IsValid

func (p TimePoint) IsValid() bool

func (TimePoint) IsValids

func (p TimePoint) IsValids() bool

func (TimePoint) PointValueStr

func (p TimePoint) PointValueStr() []string

func (TimePoint) Timestamp

func (p TimePoint) Timestamp() float64

func (TimePoint) Value

func (p TimePoint) Value() float64

func (TimePoint) Values

func (p TimePoint) Values() []float64

type TimeRange

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

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

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

type TimeSeries

type TimeSeries struct {
	RawName string            `json:"raw_name"`
	Columns []string          `json:"columns"`
	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

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

type TsdbQueryEndpoint

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

Directories

Path Synopsis
driver

Jump to

Keyboard shortcuts

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