prom

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMetricSet

func NewMetricSet(name, help string) *metricSet

func PromMetricToString

func PromMetricToString(m PromMetric) string

Types

type Alert

type Alert struct {
	Name   string
	Labels map[string]string
}

func (Alert) MLabels

func (a Alert) MLabels() map[string]string

func (Alert) String

func (a Alert) String() string

type LabelSet

type LabelSet struct {
	Labels map[string]string
}

func (LabelSet) MLabels

func (ls LabelSet) MLabels() map[string]string

type Loader

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

func NewLoader

func NewLoader(prometheusURL string) (*Loader, error)

func (Loader) LoadAlerts

func (c Loader) LoadAlerts(ctx context.Context, t time.Time) ([]Alert, error)

func (Loader) LoadAlertsRange

func (c Loader) LoadAlertsRange(ctx context.Context, start, end time.Time, step time.Duration) (RangeVector, error)

func (Loader) LoadVectorRange

func (c Loader) LoadVectorRange(ctx context.Context, query string, start, end time.Time, step time.Duration) (RangeVector, error)

type Matrix

type Matrix struct {
	Metrics []PromMetric
	Values  [][]model.SampleValue
	Start   model.Time
	End     model.Time
	Step    time.Duration
}

Matrix is a dense matrix of time series aligned by time.

type Metric

type Metric struct {
	Labels prom.Labels
	Value  float64
}

type MetricSet

type MetricSet interface {
	prometheus.Collector
	Update(metrics []Metric)
}

MetricSet is an expasion of prometheus.Collector interface that allows batch updates of metrics. Useful when processing a set of metrics that are later exposed to Prometheus via different metric.

type PromMetric

type PromMetric interface {
	MLabels() map[string]string
}

TODO: Replace with LabelSet and get rid of Alerts struct

  • it's unnecessary complex.

type Range

type Range struct {
	Metric  PromMetric
	Samples []model.SamplePair
	Step    time.Duration
}

type RangeVector

type RangeVector []Range

func (RangeVector) Expand

func (v RangeVector) Expand() Matrix

Expand converts a RangeVector to a dense Matrix.

The dense matrix is quite an expensive structure. We initially used it for searching for alerts changes, but we used interval-based approach instead. We keep this function for possible future use.

func (RangeVector) MaxTime

func (v RangeVector) MaxTime() model.Time

func (RangeVector) MinTime

func (v RangeVector) MinTime() model.Time

Jump to

Keyboard shortcuts

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