datasource

package
v0.0.0-...-6473eef Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidType is thrown when the provided datasource in a datasource file is invalid.
	ErrInvalidType = errors.New("invalid datasource type")
)

Functions

func New

func New(dir string) (map[string]Client, error)

func QueryInterpolation

func QueryInterpolation(query string, variables map[string]string) (string, error)

Types

type Auth

type Auth struct {
	Username              string `yaml:"username"`
	Password              string `yaml:"password"`
	Token                 string `yaml:"token"`
	InsecureSkipTLSVerify bool   `yaml:"insecureSkipTLSVerify"`
}

type Client

type Client interface {
	GetVariableValues(query, label string, start, end time.Time) ([]string, error)
	GetData(queries, labels []string, start, end time.Time) (*Data, error)
	GetTableData(queries, labels []string) (*TableData, error)
	GetSuggestions() ([]string, error)
}

type Data

type Data struct {
	Timestamps map[int]string
	Series     []Series
}

type Datasource

type Datasource struct {
	Type    string  `yaml:"type"`
	Name    string  `yaml:"name"`
	URL     string  `yaml:"url"`
	Auth    Auth    `yaml:"auth"`
	Options Options `yaml:"options"`
}

type Options

type Options struct {
	MaxPoints int64 `yaml:"maxPoints"`
	Step      int64 `yaml:"step"`
}

type Prometheus

type Prometheus struct {
	// contains filtered or unexported fields
}

func NewPrometheusClient

func NewPrometheusClient(datasource Datasource) (*Prometheus, error)

func (*Prometheus) GetData

func (p *Prometheus) GetData(queries, labels []string, start, end time.Time) (*Data, error)

func (*Prometheus) GetSuggestions

func (p *Prometheus) GetSuggestions() ([]string, error)

func (*Prometheus) GetTableData

func (p *Prometheus) GetTableData(queries, labels []string) (*TableData, error)

func (*Prometheus) GetVariableValues

func (p *Prometheus) GetVariableValues(query, label string, start, end time.Time) ([]string, error)

type Series

type Series struct {
	Label  string
	Points []float64
}

type TableData

type TableData map[string]map[string]interface{}

Jump to

Keyboard shortcuts

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