prometheus

package
v2.3.0-alpha.2+incompa... Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Label

type Label struct {
	Name  []byte
	Value []byte
}

Label contains a label name and value.

func NewLabel

func NewLabel(name, value string) Label

NewLabel provides a convenient ways of constructing a Label from strings.

type Labels

type Labels []Label

Labels contains the set of Label instances for a metric.

func (Labels) ToBytes

func (labels Labels) ToBytes() []byte

ToBytes renders the label name and value to wire format.

func (Labels) With

func (labels Labels) With(name, value string) Labels

With returns a new Labels with the additional labels added.

type Metric

type Metric struct {
	Name         []byte
	Labels       Labels
	Value        int64
	Milliseconds int64
}

Metric represents a single Prometheus metric line, including its labels and timestamp.

func ParseMetric

func ParseMetric(s []byte) (*Metric, error)

ParseMetric parses a single Prometheus metric line.

Note: The implementation currently only supports integer values and also doesn't handle escaped characters nor multiple sequential whitespace characters. This is OK for now because this only needs to support metrics generated by the various influx-spout components.

func (*Metric) String

func (m *Metric) String() string

func (*Metric) ToBytes

func (m *Metric) ToBytes() []byte

ToBytes renders the metric to wire format.

type MetricSet

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

MetricSet is a collection of metrics. Metrics are indexed by name and labels combined. Existing metrics will be updated if an update for the same name and labels arrives.

func NewMetricSet

func NewMetricSet() *MetricSet

NewMetricSet returns an empty MetricSet.

func ParseMetrics

func ParseMetrics(s []byte) (*MetricSet, error)

ParseMetrics parses multiple Prometheus metric lines, returning a MetricSet.

func (*MetricSet) All

func (set *MetricSet) All() []*Metric

All returns all metrics in the set as a slice.

func (*MetricSet) ToBytes

func (set *MetricSet) ToBytes() []byte

ToBytes serialise the metrics contained in the MetricSet to the Prometheus exposition format.

func (*MetricSet) Update

func (set *MetricSet) Update(m *Metric)

Update adds a new metric or updates an existing one in the set, overwriting previous values.

func (*MetricSet) UpdateFromSet

func (set *MetricSet) UpdateFromSet(other *MetricSet)

UpdateFromSet updates the values in the set from another MetricSet.

Jump to

Keyboard shortcuts

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