prompb

package
v1.122.13 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: Apache-2.0 Imports: 9 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LabelsToString added in v1.110.15

func LabelsToString(labels []Label) string

LabelsToString converts labels to Prometheus-compatible string

func PutWriteRequestUnmarshaler added in v1.110.26

func PutWriteRequestUnmarshaler(wru *WriteRequestUnmarshaler)

PutWriteRequestUnmarshaler returns wru to the pool.

The caller mustn't access wru fields after returning wru to the pool.

Types

type Label

type Label struct {
	// Name is label name.
	Name string

	// Value is label value.
	Value string
}

Label is a timeseries label.

type MetricMetadata added in v1.102.25

type MetricMetadata struct {
	// Represents the metric type, these match the set from Prometheus.
	// Refer to https://github.com/prometheus/common/blob/95acce133ca2c07a966a71d475fb936fc282db18/model/metadata.go for details.
	Type             MetricType
	MetricFamilyName string
	Help             string
	Unit             string

	// Additional fields to allow storing and querying metadata in multitenancy.
	AccountID uint32
	ProjectID uint32
}

MetricMetadata represents additional meta information for specific MetricFamilyName.

Refer to https://github.com/prometheus/prometheus/blob/c5282933765ec322a0664d0a0268f8276e83b156/prompb/types.proto#L21

func ResetMetadata added in v1.110.15

func ResetMetadata(mms []MetricMetadata) []MetricMetadata

ResetMetadata clears all the GC references from mms and returns an empty mms ready for further use.

type MetricType added in v1.110.26

type MetricType uint32

MetricType represents the Prometheus type of a metric.

https://github.com/prometheus/prometheus/blob/c5282933765ec322a0664d0a0268f8276e83b156/prompb/types.pb.go#L28C1-L39C2 https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#metric-types

const (
	// MetricTypeUnknown represents a Prometheus Unknown-typed metric
	MetricTypeUnknown MetricType = 0
	// MetricTypeCounter represents a Prometheus Counter
	MetricTypeCounter MetricType = 1
	// MetricTypeGauge represents a Prometheus Gauge
	MetricTypeGauge MetricType = 2
	// MetricTypeHistogram represents a Prometheus Histogram
	MetricTypeHistogram MetricType = 3
	// MetricTypeGaugeHistogram represents a Prometheus GaugeHistogram
	MetricTypeGaugeHistogram MetricType = 4
	// MetricTypeSummary represents a Prometheus Summary
	MetricTypeSummary MetricType = 5
	// MetricTypeInfo represents a Prometheus Info metric
	MetricTypeInfo MetricType = 6
	// MetricTypeStateset represents a Prometheus StateSet metric
	MetricTypeStateset MetricType = 7
)

func (MetricType) String added in v1.110.26

func (mt MetricType) String() string

String returns human-readable string for mt.

type Sample

type Sample struct {
	// Value is sample value.
	Value float64

	// Timestamp is unix timestamp for the sample in milliseconds.
	Timestamp int64
}

Sample is a timeseries sample.

type TimeSeries

type TimeSeries struct {
	// Labels is a list of labels for the given TimeSeries
	Labels []Label

	// Samples is a list of samples for the given TimeSeries
	Samples []Sample
}

TimeSeries is a timeseries.

func ResetTimeSeries added in v1.110.15

func ResetTimeSeries(tss []TimeSeries) []TimeSeries

ResetTimeSeries clears all the GC references from tss and returns an empty tss ready for further use.

type WriteRequest

type WriteRequest struct {
	// Timeseries is a list of time series in the given WriteRequest
	Timeseries []TimeSeries

	// Metadata is a list of metadata info in the given WriteRequest
	Metadata []MetricMetadata
}

WriteRequest represents Prometheus remote write API request.

func (*WriteRequest) IsEmpty added in v1.110.16

func (m *WriteRequest) IsEmpty() bool

IsEmpty checks if the WriteRequest has data to push.

func (*WriteRequest) MarshalProtobuf added in v1.110.15

func (wr *WriteRequest) MarshalProtobuf(dst []byte) []byte

MarshalProtobuf marshals wr to dst and returns the result.

func (*WriteRequest) Reset

func (wr *WriteRequest) Reset()

Reset resets wr for subsequent reuse.

type WriteRequestUnmarshaler added in v1.110.16

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

WriteRequestUnmarshaler is reusable unmarshaler for WriteRequest protobuf messages.

It maintains internal pools for labels and samples to reduce memory allocations. See UnmarshalProtobuf for details on how to use it.

func GetWriteRequestUnmarshaler added in v1.110.26

func GetWriteRequestUnmarshaler() *WriteRequestUnmarshaler

GetWriteRequestUnmarshaler returns WriteRequestUnmarshaler from the pool.

Return the WriteRequestUnmarshaler to the pool when it is no longer needed via PutWriteRequestUnmarshaler call.

func (*WriteRequestUnmarshaler) Reset added in v1.110.16

func (wru *WriteRequestUnmarshaler) Reset()

Reset resets wru, so it could be re-used.

func (*WriteRequestUnmarshaler) UnmarshalProtobuf added in v1.110.16

func (wru *WriteRequestUnmarshaler) UnmarshalProtobuf(src []byte) (*WriteRequest, error)

UnmarshalProtobuf parses the given Protobuf-encoded `src` into an internal WriteRequest instance and returns a pointer to it.

This method avoids allocations by reusing preallocated slices and pools.

Notes:

  • The `src` slice must remain unchanged for the lifetime of the returned WriteRequest, as the WriteRequest retain references to it.
  • The returned WriteRequest is only valid until the next call to UnmarshalProtobuf, which reuses internal buffers and structs.

Jump to

Keyboard shortcuts

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