tsdb

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 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 client response")
	ErrMissingConfig       = errors.New("global config not found in client config")
	ErrFailedTypeAssertion = errors.New("failed type assertion")
)

Custom errors.

Functions

This section is empty.

Types

type Client

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

Client struct.

func New

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

New returns a new instance of Client.

func (*Client) Available

func (t *Client) Available() bool

Available returns true if Client is alive.

func (*Client) Delete

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

Delete time series with given labels.

func (*Client) Labels

func (t *Client) Labels(ctx context.Context, matchers []string, start time.Time, end time.Time) ([]string, error)

Labels makes a Client query to get list of labels.

func (*Client) Ping

func (t *Client) Ping() error

Ping attempts to ping Client.

func (*Client) Query

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

Query makes a Client query.

func (*Client) RangeQuery

func (t *Client) RangeQuery(
	ctx context.Context,
	query string,
	startTime time.Time,
	endTime time.Time,
	step time.Duration,
	timeout time.Duration,
) (model.Matrix, error)

RangeQuery makes a Client range query.

func (*Client) Series

func (t *Client) Series(ctx context.Context, matchers []string, start time.Time, end time.Time) ([]model.LabelSet, error)

Series makes a Client query to get series.

func (*Client) Settings

func (t *Client) Settings(ctx context.Context) *Settings

Settings returns selected Client config settings.

func (*Client) String

func (t *Client) String() string

String implements stringer method for Client.

type Config

type Config struct {
	Global struct {
		ScrapeInterval     model.Duration `yaml:"scrape_interval"`
		EvaluationInterval model.Duration `yaml:"evaluation_interval"`
	} `yaml:"global"`
}

Config is Prometheus config representation.

type Data

type Data struct {
	ResultType string   `json:"resultType"`
	Result     []Result `json:"result"`
}

type Metric

type Metric map[string]float64

Metric defines Client metrics.

type Response

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

Response is the Client response model.

type Result

type Result struct {
	Metric map[string]string `json:"metric"`
	Value  any               `json:"value"`
	Values []any             `json:"values"`
}

type Settings

type Settings struct {
	ScrapeInterval     time.Duration
	EvaluationInterval time.Duration
	RateInterval       time.Duration
	QueryLookbackDelta time.Duration
	QueryTimeout       time.Duration
	QueryMaxSamples    int64
	RetentionPeriod    time.Duration
}

Jump to

Keyboard shortcuts

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