model

package
v0.0.0-...-d79780e Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnnotationToMetaLabels

func AnnotationToMetaLabels(lbls labels.Labels, annotation types.MetricAnnotations) labels.Labels

AnnotationToMetaLabels convert annotation to meta-labels (labels starting with __) and append them to existing labels. It's valid to provide nil for initial labels.

func CollectorToFamilies

func CollectorToFamilies(metrics []prometheus.Metric) ([]*dto.MetricFamily, error)

func DTO2Labels

func DTO2Labels(name string, input []*dto.LabelPair) map[string]string

func DropMetaLabels

func DropMetaLabels(lbls labels.Labels) labels.Labels

DropMetaLabels delete all labels which start with __ (with exception to __name__). The input is modified.

func DropMetaLabelsFromFamilies

func DropMetaLabelsFromFamilies(families []*dto.MetricFamily)

DropMetaLabelsFromFamilies delete all labels which start with __ (with exception to __name__). The input is modified.

func FamiliesDeepCopy

func FamiliesDeepCopy(families []*dto.MetricFamily) []*dto.MetricFamily

func FamiliesToCollector

func FamiliesToCollector(families []*dto.MetricFamily) ([]prometheus.Metric, error)

FamiliesToCollector convert metric family to prometheus.Metric. Note: meta-label are not kept in this conversion.

func FamiliesToMetricPoints

func FamiliesToMetricPoints(
	defaultTS time.Time,
	families []*dto.MetricFamily,
	dropMetaLabels bool,
) []types.MetricPoint

func FamiliesToNameAndItem

func FamiliesToNameAndItem(families []*dto.MetricFamily)

FamiliesToNameAndItem converts labels of each metrics to just name + item. It kept meta-label unchanged. The input is modified.

func FamilyConvertType

func FamilyConvertType(mf *dto.MetricFamily, targetType dto.MetricType)

FamilyConvertType convert a MetricFamilty to another type. Some information may be lost in the process.

func FixType

func FixType(m *dto.Metric, wantType dto.MetricType)

FixType changes the type of a metric. Some information may be lost in the process.

func Labels2DTO

func Labels2DTO(lbls labels.Labels) []*dto.LabelPair

func MetaLabelsToAnnotation

func MetaLabelsToAnnotation(lbls labels.Labels) types.MetricAnnotations

MetaLabelsToAnnotation extract from meta-labels some annotations. It mostly does the opposite of AnnotationToMetaLabels. Labels aren't modified.

func MetricPointsToFamilies

func MetricPointsToFamilies(points []types.MetricPoint) []*dto.MetricFamily

func SamplesToMetricFamily

func SamplesToMetricFamily(samples []promql.Sample, mType *dto.MetricType) (*dto.MetricFamily, error)

SamplesToMetricFamily convert a list of sample to a MetricFamilty of given type. The mType could be nil which will use the default of MetricType_UNTYPED. All samples must belong to the same family, that is have the same name.

func SendPointsToAppender

func SendPointsToAppender(points []types.MetricPoint, app storage.Appender) error

SendPointsToAppender append all points to given appender. It will mutate points's labels to include some meta-labels known by Registry for some annotation. This method will not Commit or Rollback on the Appender.

Types

type AppenableOfAppender

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

func NewFromAppender

func NewFromAppender(app storage.Appender) *AppenableOfAppender

NewFromAppender create an Appenable from an appender. The result appenders created from this Appendable are thread-safe, but call to Commit() or Rollback() will affect all appenders.

func (*AppenableOfAppender) Appender

type BufferAppender

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

func NewBufferAppender

func NewBufferAppender() *BufferAppender

NewBufferAppender return a new appender that store sample in-memory.

func (*BufferAppender) Append

func (*BufferAppender) AppendCTZeroSample

func (a *BufferAppender) AppendCTZeroSample(_ storage.SeriesRef, _ labels.Labels, _, _ int64) (storage.SeriesRef, error)

func (*BufferAppender) AppendExemplar

func (*BufferAppender) AsMF

func (a *BufferAppender) AsMF() ([]*dto.MetricFamily, error)

func (*BufferAppender) Commit

func (a *BufferAppender) Commit() error

func (*BufferAppender) CommitCopyAndReset

func (a *BufferAppender) CommitCopyAndReset(app storage.Appender) error

CommitCopyAndReset calls Commit, CopyTo and Reset atomically.

func (*BufferAppender) CopyTo

func (a *BufferAppender) CopyTo(app storage.Appender) error

CopyTo copy committed sample to given appender. It don't call Commit() on any Appender.

func (*BufferAppender) FixSampleTimestamp

func (a *BufferAppender) FixSampleTimestamp(ts time.Time)

func (*BufferAppender) Reset

func (a *BufferAppender) Reset()

func (*BufferAppender) Rollback

func (a *BufferAppender) Rollback() error

func (*BufferAppender) UpdateMetadata

Jump to

Keyboard shortcuts

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