Documentation
¶
Index ¶
- Constants
- Variables
- func PutTimeSeriesIntoPool(ts *TimeSeriesBinary)
- func PutTimeSeriesSliceIntoPool(tss []*TimeSeriesBinary)
- func ToPromBucketSpans(bss []BucketSpan) []prompb.BucketSpan
- type BasicAuth
- type BucketSpan
- func (z *BucketSpan) DecodeMsg(dc *msgp.Reader) (err error)
- func (z BucketSpan) EncodeMsg(en *msgp.Writer) (err error)
- func (z BucketSpan) MarshalMsg(b []byte) (o []byte, err error)
- func (z BucketSpan) Msgsize() (s int)
- func (bs *BucketSpan) ToPromBucketSpan() prompb.BucketSpan
- func (z *BucketSpan) UnmarshalMsg(bts []byte) (o []byte, err error)
- type CategoryStats
- type ConnectionConfig
- type Data
- type DataHandle
- type FileStorage
- type FloatHistogram
- func (z *FloatHistogram) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *FloatHistogram) EncodeMsg(en *msgp.Writer) (err error)
- func (z *FloatHistogram) MarshalMsg(b []byte) (o []byte, err error)
- func (z *FloatHistogram) Msgsize() (s int)
- func (h *FloatHistogram) ToPromFloatHistogram() prompb.Histogram
- func (z *FloatHistogram) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Histogram
- func (z *Histogram) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *Histogram) EncodeMsg(en *msgp.Writer) (err error)
- func (z *Histogram) MarshalMsg(b []byte) (o []byte, err error)
- func (z *Histogram) Msgsize() (s int)
- func (h *Histogram) ToPromHistogram() prompb.Histogram
- func (z *Histogram) UnmarshalMsg(bts []byte) (o []byte, err error)
- type HistogramCount
- func (z *HistogramCount) DecodeMsg(dc *msgp.Reader) (err error)
- func (z HistogramCount) EncodeMsg(en *msgp.Writer) (err error)
- func (z HistogramCount) MarshalMsg(b []byte) (o []byte, err error)
- func (z HistogramCount) Msgsize() (s int)
- func (z *HistogramCount) UnmarshalMsg(bts []byte) (o []byte, err error)
- type HistogramZeroCount
- func (z *HistogramZeroCount) DecodeMsg(dc *msgp.Reader) (err error)
- func (z HistogramZeroCount) EncodeMsg(en *msgp.Writer) (err error)
- func (z HistogramZeroCount) MarshalMsg(b []byte) (o []byte, err error)
- func (z HistogramZeroCount) Msgsize() (s int)
- func (z *HistogramZeroCount) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Histograms
- type NetworkClient
- type NetworkStats
- type Serializer
- type SerializerConfig
- type SerializerStats
- type SeriesGroup
- type TimeSeriesBinary
- func (z *TimeSeriesBinary) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *TimeSeriesBinary) EncodeMsg(en *msgp.Writer) (err error)
- func (ts *TimeSeriesBinary) FillLabelMapping(strMapToInt map[string]uint32)
- func (ts *TimeSeriesBinary) FromFloatHistogram(timestamp int64, h *histogram.FloatHistogram)
- func (ts *TimeSeriesBinary) FromHistogram(timestamp int64, h *histogram.Histogram)
- func (ts TimeSeriesBinary) IsMetadata() bool
- func (z *TimeSeriesBinary) MarshalMsg(b []byte) (o []byte, err error)
- func (z *TimeSeriesBinary) Msgsize() (s int)
- func (z *TimeSeriesBinary) UnmarshalMsg(bts []byte) (o []byte, err error)
Constants ¶
const AlloyFileVersion = "alloy.metrics.queue.v1"
const MetaHelp = "__alloy_metadata_help__"
const MetaType = "__alloy_metadata_type__"
const MetaUnit = "__alloy_metadata_unit__"
Variables ¶
var OutStandingTimeSeriesBinary = atomic.Int32{}
Functions ¶
func PutTimeSeriesIntoPool ¶
func PutTimeSeriesIntoPool(ts *TimeSeriesBinary)
func PutTimeSeriesSliceIntoPool ¶
func PutTimeSeriesSliceIntoPool(tss []*TimeSeriesBinary)
func ToPromBucketSpans ¶
func ToPromBucketSpans(bss []BucketSpan) []prompb.BucketSpan
Types ¶
type BucketSpan ¶
func FromPromSpan ¶
func FromPromSpan(spans []histogram.Span) []BucketSpan
func (*BucketSpan) DecodeMsg ¶
func (z *BucketSpan) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (BucketSpan) EncodeMsg ¶
func (z BucketSpan) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (BucketSpan) MarshalMsg ¶
func (z BucketSpan) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (BucketSpan) Msgsize ¶
func (z BucketSpan) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*BucketSpan) ToPromBucketSpan ¶
func (bs *BucketSpan) ToPromBucketSpan() prompb.BucketSpan
func (*BucketSpan) UnmarshalMsg ¶
func (z *BucketSpan) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type CategoryStats ¶
type ConnectionConfig ¶
type ConnectionConfig struct {
// URL is the URL of the Prometheus server.
URL string
// BasicAuth holds the username and password for basic HTTP authentication.
BasicAuth *BasicAuth
// BearerToken is the bearer token for the Prometheus server.
BearerToken string
// UserAgent is the User-Agent header sent to the Prometheus server.
UserAgent string
// Timeout specifies the duration for which the connection will wait for a response before timing out.
Timeout time.Duration
// RetryBackoff is the duration between retries when a network request fails.
// The next retry will happen after RetryBackoff + (RetryBackoff * attempt number).
RetryBackoff time.Duration
// MaxRetryAttempts specifies the maximum number of times a request will be retried
// if it fails. The next retry will happen after RetryBackoff + (RetryBackoff * attempt number).
// If this is set to 0, no retries are attempted.
MaxRetryAttempts uint
// BatchCount is the number of time series to batch together before sending to the network.
BatchCount int
// FlushInterval specifies the duration between each flush of the network
// buffer. If no data is available, the buffer is not flushed.
FlushInterval time.Duration
// ExternalLabels specifies the external labels to be added to all samples
// sent to the Prometheus server.
ExternalLabels map[string]string
// Connections is the number of concurrent connections to use for sending data.
Connections uint
}
ConnectionConfig holds configuration details for network connections. It includes various options such as authentication, timeouts, retry policies, batching, and connection management settings.
func (ConnectionConfig) Equals ¶
func (cc ConnectionConfig) Equals(bb ConnectionConfig) bool
type DataHandle ¶
type FileStorage ¶
type FloatHistogram ¶
type FloatHistogram struct {
Count HistogramCount
Sum float64
Schema int32
ZeroThreshold float64
ZeroCount HistogramZeroCount
NegativeSpans []BucketSpan
NegativeDeltas []int64
NegativeCounts []float64
PositiveSpans []BucketSpan
PositiveDeltas []int64
PositiveCounts []float64
ResetHint int32
TimestampMillisecond int64
}
func (*FloatHistogram) DecodeMsg ¶
func (z *FloatHistogram) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*FloatHistogram) EncodeMsg ¶
func (z *FloatHistogram) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*FloatHistogram) MarshalMsg ¶
func (z *FloatHistogram) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*FloatHistogram) Msgsize ¶
func (z *FloatHistogram) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*FloatHistogram) ToPromFloatHistogram ¶
func (h *FloatHistogram) ToPromFloatHistogram() prompb.Histogram
func (*FloatHistogram) UnmarshalMsg ¶
func (z *FloatHistogram) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Histogram ¶
type Histogram struct {
Count HistogramCount
Sum float64
Schema int32
ZeroThreshold float64
ZeroCount HistogramZeroCount
NegativeSpans []BucketSpan
NegativeBuckets []int64
NegativeCounts []float64
PositiveSpans []BucketSpan
PositiveBuckets []int64
PositiveCounts []float64
ResetHint int32
TimestampMillisecond int64
}
func (*Histogram) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*Histogram) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Histogram) ToPromHistogram ¶
type HistogramCount ¶
func (*HistogramCount) DecodeMsg ¶
func (z *HistogramCount) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (HistogramCount) EncodeMsg ¶
func (z HistogramCount) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (HistogramCount) MarshalMsg ¶
func (z HistogramCount) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (HistogramCount) Msgsize ¶
func (z HistogramCount) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*HistogramCount) UnmarshalMsg ¶
func (z *HistogramCount) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type HistogramZeroCount ¶
func (*HistogramZeroCount) DecodeMsg ¶
func (z *HistogramZeroCount) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (HistogramZeroCount) EncodeMsg ¶
func (z HistogramZeroCount) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (HistogramZeroCount) MarshalMsg ¶
func (z HistogramZeroCount) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (HistogramZeroCount) Msgsize ¶
func (z HistogramZeroCount) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*HistogramZeroCount) UnmarshalMsg ¶
func (z *HistogramZeroCount) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Histograms ¶
type Histograms struct {
Histogram *Histogram
FloatHistogram *FloatHistogram
}
func (*Histograms) DecodeMsg ¶
func (z *Histograms) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*Histograms) EncodeMsg ¶
func (z *Histograms) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*Histograms) MarshalMsg ¶
func (z *Histograms) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*Histograms) Msgsize ¶
func (z *Histograms) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Histograms) UnmarshalMsg ¶
func (z *Histograms) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type NetworkClient ¶
type NetworkClient interface {
Start()
Stop()
// SendSeries will block if the network caches are full.
SendSeries(ctx context.Context, d *TimeSeriesBinary) error
// SendMetadata will block if the network caches are full.
SendMetadata(ctx context.Context, d *TimeSeriesBinary) error
// UpdateConfig is a synchronous call and will only return once the config
// is applied or an error occurs.
UpdateConfig(ctx context.Context, cfg ConnectionConfig) error
}
type NetworkStats ¶
type NetworkStats struct {
Series CategoryStats
Histogram CategoryStats
Metadata CategoryStats
SendDuration time.Duration
NewestTimestamp int64
SeriesBytes int
MetadataBytes int
}
func (NetworkStats) Total429 ¶
func (ns NetworkStats) Total429() int
func (NetworkStats) Total5XX ¶
func (ns NetworkStats) Total5XX() int
func (NetworkStats) TotalFailed ¶
func (ns NetworkStats) TotalFailed() int
func (NetworkStats) TotalRetried ¶
func (ns NetworkStats) TotalRetried() int
func (NetworkStats) TotalSent ¶
func (ns NetworkStats) TotalSent() int
type Serializer ¶
type Serializer interface {
Start()
Stop()
SendSeries(ctx context.Context, data *TimeSeriesBinary) error
SendMetadata(ctx context.Context, data *TimeSeriesBinary) error
UpdateConfig(ctx context.Context, cfg SerializerConfig) error
}
Serializer handles converting a set of signals into a binary representation to be written to storage.
type SerializerConfig ¶
type SerializerStats ¶
type SeriesGroup ¶
type SeriesGroup struct {
Strings []string
Series []*TimeSeriesBinary
Metadata []*TimeSeriesBinary
}
SeriesGroup is the holder for TimeSeries, Metadata, and the strings array. When serialized the Labels Key,Value array will be transformed into LabelNames and LabelsValues that point to the index in Strings. This deduplicates the strings and decreases the size on disk.
func DeserializeToSeriesGroup ¶
func DeserializeToSeriesGroup(sg *SeriesGroup, buf []byte) (*SeriesGroup, []byte, error)
DeserializeToSeriesGroup transforms a buffer to a SeriesGroup and converts the stringmap + indexes into actual Labels.
func (*SeriesGroup) DecodeMsg ¶
func (z *SeriesGroup) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*SeriesGroup) EncodeMsg ¶
func (z *SeriesGroup) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*SeriesGroup) MarshalMsg ¶
func (z *SeriesGroup) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*SeriesGroup) Msgsize ¶
func (z *SeriesGroup) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*SeriesGroup) UnmarshalMsg ¶
func (z *SeriesGroup) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type TimeSeriesBinary ¶
type TimeSeriesBinary struct {
// Labels are not serialized to msgp, instead we store separately a dictionary of strings and use `LabelNames` and `LabelValues` to refer to the dictionary by ID.
Labels labels.Labels `msg:"-"`
LabelsNames []uint32
LabelsValues []uint32
TS int64
Value float64
Hash uint64
Histograms Histograms
}
TimeSeriesBinary is an optimized format for handling metrics and metadata. It should never be instantiated directly but instead use GetTimeSeriesFromPool and PutTimeSeriesSliceIntoPool. This allows us to reuse these objects and avoid allocations.
func GetTimeSeriesFromPool ¶
func GetTimeSeriesFromPool() *TimeSeriesBinary
func (*TimeSeriesBinary) DecodeMsg ¶
func (z *TimeSeriesBinary) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*TimeSeriesBinary) EncodeMsg ¶
func (z *TimeSeriesBinary) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*TimeSeriesBinary) FillLabelMapping ¶
func (ts *TimeSeriesBinary) FillLabelMapping(strMapToInt map[string]uint32)
FillLabelMapping is what does the conversion from labels.Labels to LabelNames and LabelValues while filling in the string map, that is later converted to []string.
func (*TimeSeriesBinary) FromFloatHistogram ¶
func (ts *TimeSeriesBinary) FromFloatHistogram(timestamp int64, h *histogram.FloatHistogram)
func (*TimeSeriesBinary) FromHistogram ¶
func (ts *TimeSeriesBinary) FromHistogram(timestamp int64, h *histogram.Histogram)
func (TimeSeriesBinary) IsMetadata ¶
func (ts TimeSeriesBinary) IsMetadata() bool
IsMetadata is used because it's easier to store metadata as a set of labels.
func (*TimeSeriesBinary) MarshalMsg ¶
func (z *TimeSeriesBinary) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*TimeSeriesBinary) Msgsize ¶
func (z *TimeSeriesBinary) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*TimeSeriesBinary) UnmarshalMsg ¶
func (z *TimeSeriesBinary) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler