instance

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Address  string `json:"address"`
	Username string `json:"username"`
	Password string `json:"password"`
	Token    string `json:"token"`
}

Config is the structure of the configuration for a single Prometheus instance.

type Datum

type Datum struct {
	X int64    `json:"x"`
	Y *float64 `json:"y"`
}

Datum is the structure of a single data point of a metric. The y value must be a pointer, because when the value is NaN we can not set the value (NaN in the JSON representation will throw an error). For that NaN values will always be null.

type Instance

type Instance interface {
	GetName() string
	GetVariable(ctx context.Context, label, query, queryType string, timeStart, timeEnd int64) ([]string, error)
	GetMetrics(ctx context.Context, queries []Query, resolution string, timeStart, timeEnd int64) (*Metrics, error)
	GetTableData(ctx context.Context, queries []Query, timeEnd int64) (map[string]map[string]string, error)
	GetLabelValues(ctx context.Context, searchTerm string) ([]string, error)
}

Instance is the interface for a single Prometheus instance, which can be added via the configuration file.

func New

func New(name string, options map[string]any) (Instance, error)

New returns a new Prometheus instance for the given configuration.

type Metric

type Metric struct {
	ID    string  `json:"id"`
	Label string  `json:"label"`
	Min   float64 `json:"min"`
	Max   float64 `json:"max"`
	Avg   float64 `json:"avg"`
	Data  []Datum `json:"data"`
}

Metric is the response format for a single metric. Each metric must have an ID and label. We also add the min, max and average for the returned data.

type Metrics

type Metrics struct {
	StartTime int64    `json:"startTime"`
	EndTime   int64    `json:"endTime"`
	Min       float64  `json:"min"`
	Max       float64  `json:"max"`
	Metrics   []Metric `json:"metrics"`
}

Metrics is the structure for the returned metrics from the Prometheus metrics API endpoint. It contains a list of metrics, the start and end time for the query and the min and max value accross all time series.

type Query

type Query struct {
	Query string `json:"query"`
	Label string `json:"label"`
}

Query is the structure of a query. Each query consists of the PromQL query and an optional label, which can be displayed in the legend of a chart.

Jump to

Keyboard shortcuts

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