tsdb

package
v0.0.0-...-2b29b9b Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 14 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

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

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 FormatRawName

func FormatRawName(idx int, name string, groupByTags []string, tags map[string]string, diffTagKeys sets.String) string

func GetIntervalFrom

func GetIntervalFrom(dsInfo *DataSource, queryModel *Query, defaultInterval time.Duration) (time.Duration, error)

func IsValidDataSource

func IsValidDataSource(dsType string) error

func NewIntervalCalculator

func NewIntervalCalculator(opt *IntervalOptions) *intervalCalculator

func NewTimeSeries

func NewTimeSeries(
	name string,
	rawName string,
	columns []string,
	points api.TimeSeriesPoints,
	tags map[string]string,
) *api.TimeSeries

func RegisterTsdbQueryEndpoint

func RegisterTsdbQueryEndpoint(dataSourceType string, fn GetTsdbQueryEndpointFn)

func TryParseUnixMsEpoch

func TryParseUnixMsEpoch(val string) (time.Time, bool)

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        api.QueryResultMeta `json:"meta"`
	Series      api.TimeSeriesSlice `json:"series"`
	Tables      []*Table            `json:"tables"`
	Dataframes  [][]byte            `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 *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 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 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)
	FilterMeasurement(ctx context.Context, ds *DataSource, from, to string, ms *monitor.InfluxMeasurement, tagFilter *monitor.MetricQueryTag) (*monitor.InfluxMeasurement, error)
	FillSelect(query *monitor.AlertQuery, isAlert bool) *monitor.AlertQuery
	FillGroupBy(query *monitor.AlertQuery, inputQuery *monitor.MetricQueryInput, tagId string, isAlert bool) *monitor.AlertQuery
}

func GetTsdbQueryEndpointFor

func GetTsdbQueryEndpointFor(dsInfo *DataSource) (TsdbQueryEndpoint, error)

Directories

Path Synopsis
driver

Jump to

Keyboard shortcuts

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