tsdb

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package tsdb implements TSDB client

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingData         = errors.New("missing data in TSDB response")
	ErrMissingConfig       = errors.New("global config not found in TSDB config")
	ErrFailedTypeAssertion = errors.New("failed type assertion")
)

Custom errors.

Functions

func Request

func Request(ctx context.Context, url string, client *http.Client) (interface{}, error)

Types

type Metric

type Metric map[string]float64

Metric defines TSDB metrics.

type RangeMetric added in v0.3.1

type RangeMetric map[string][]interface{}

RangeMetric defines TSDB range metrics.

type Response

type Response struct {
	Status    string      `json:"status"`
	Data      interface{} `json:"data,omitempty"`
	ErrorType string      `json:"errorType,omitempty"`
	Error     string      `json:"error,omitempty"`
	Warnings  []string    `json:"warnings,omitempty"`
}

Response is the TSDB response model.

type TSDB

type TSDB struct {
	URL    *url.URL
	Client *http.Client
	Logger *slog.Logger
	// contains filtered or unexported fields
}

TSDB struct.

func New added in v0.2.0

func New(webURL string, config config_util.HTTPClientConfig, logger *slog.Logger) (*TSDB, error)

New returns a new instance of TSDB.

func (*TSDB) Available

func (t *TSDB) Available() bool

Available returns true if TSDB is alive.

func (*TSDB) Config

func (t *TSDB) Config(ctx context.Context) (map[interface{}]interface{}, error)

Config returns TSDB config.

func (*TSDB) Delete

func (t *TSDB) Delete(ctx context.Context, startTime time.Time, endTime time.Time, matchers []string) error

Delete time series with given labels.

func (*TSDB) Flags

func (t *TSDB) Flags(ctx context.Context) (map[string]interface{}, error)

Flags returns CLI flags of TSDB.

func (*TSDB) GlobalConfig

func (t *TSDB) GlobalConfig(ctx context.Context) (map[string]interface{}, error)

GlobalConfig returns global config section of TSDB.

func (*TSDB) Intervals

func (t *TSDB) Intervals(ctx context.Context) map[string]time.Duration

Intervals returns scrape and evaluation intervals of TSDB.

func (*TSDB) Ping

func (t *TSDB) Ping() error

Ping attempts to ping TSDB.

func (*TSDB) Query

func (t *TSDB) Query(ctx context.Context, query string, queryTime time.Time) (Metric, error)

Query makes a TSDB query.

func (*TSDB) RangeQuery added in v0.3.1

func (t *TSDB) RangeQuery(
	ctx context.Context,
	query string,
	startTime time.Time,
	endTime time.Time,
	step string,
) (RangeMetric, error)

RangeQuery makes a TSDB range query.

func (*TSDB) RateInterval

func (t *TSDB) RateInterval(ctx context.Context) time.Duration

RateInterval returns rate interval of TSDB.

func (*TSDB) String

func (t *TSDB) String() string

String implements stringer method for TSDB.

Jump to

Keyboard shortcuts

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