tsdb

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Overview

Package tsdb implements Client 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 added in v0.6.0

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

Client struct.

func New added in v0.2.0

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

New returns a new instance of Client.

func (*Client) Available added in v0.6.0

func (t *Client) Available() bool

Available returns true if Client is alive.

func (*Client) Delete added in v0.6.0

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 added in v0.6.0

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 added in v0.6.0

func (t *Client) Ping() error

Ping attempts to ping Client.

func (*Client) Query added in v0.6.0

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

Query makes a Client query.

func (*Client) RangeQuery added in v0.6.0

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

RangeQuery makes a Client range query.

func (*Client) Series added in v0.6.0

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 added in v0.6.0

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

Settings returns selected Client config settings.

func (*Client) String added in v0.6.0

func (t *Client) String() string

String implements stringer method for Client.

type Config added in v0.6.0

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 added in v0.6.0

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

type Metric

type Metric map[string]float64

Metric defines Client metrics.

type RangeMetric added in v0.3.1

type RangeMetric map[string][]model.SamplePair

RangeMetric defines Client range 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 added in v0.6.0

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

type Settings added in v0.5.2

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

Jump to

Keyboard shortcuts

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