promutils

package
v0.26.0-victorialogs Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: Apache-2.0 Imports: 16 Imported by: 59

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses duration string in Prometheus format

func ParseTimeAt added in v1.91.0

func ParseTimeAt(s string, currentTimestamp int64) (int64, error)

ParseTimeAt parses time s in different formats, assuming the given currentTimestamp.

See https://docs.victoriametrics.com/single-server-victoriametrics/#timestamp-formats

It returns unix timestamp in nanoseconds.

func ParseTimeMsec added in v1.97.3

func ParseTimeMsec(s string) (int64, error)

ParseTimeMsec parses time s in different formats.

See https://docs.victoriametrics.com/single-server-victoriametrics/#timestamp-formats

It returns unix timestamp in milliseconds.

func PutLabels added in v1.85.0

func PutLabels(x *Labels)

PutLabels returns x, which has been obtained via GetLabels(), to the pool.

The x mustn't be used after returning to the pool.

Types

type Duration

type Duration struct {
	D time.Duration
}

Duration is duration, which must be used in Prometheus-compatible yaml configs.

func NewDuration

func NewDuration(d time.Duration) *Duration

NewDuration returns Duration for given d.

func (*Duration) Duration

func (pd *Duration) Duration() time.Duration

Duration returns duration for pd.

func (Duration) MarshalYAML

func (pd Duration) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler interface.

func (*Duration) UnmarshalYAML

func (pd *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler interface.

type Labels added in v1.85.0

type Labels struct {
	Labels []prompbmarshal.Label
}

Labels contains Prometheus labels.

func GetLabels added in v1.85.0

func GetLabels() *Labels

GetLabels returns and empty Labels instance from the pool.

The returned Labels instance must be returned to pool via PutLabels() when no longer needed.

func MustNewLabelsFromString added in v1.85.0

func MustNewLabelsFromString(metricWithLabels string) *Labels

MustNewLabelsFromString creates labels from s, which can have the form `metric{labels}`.

This function must be used only in tests. Use NewLabelsFromString in production code.

func NewLabels added in v1.85.0

func NewLabels(capacity int) *Labels

NewLabels returns Labels with the given capacity.

func NewLabelsFromMap added in v1.85.0

func NewLabelsFromMap(m map[string]string) *Labels

NewLabelsFromMap returns Labels generated from m.

func NewLabelsFromString added in v1.85.0

func NewLabelsFromString(metricWithLabels string) (*Labels, error)

NewLabelsFromString creates labels from s, which can have the form `metric{labels}`.

This function must be used only in non performance-critical code, since it allocates too much

func (*Labels) Add added in v1.85.0

func (x *Labels) Add(name, value string)

Add adds name=value label to x.

func (*Labels) AddFrom added in v1.85.0

func (x *Labels) AddFrom(src *Labels)

AddFrom adds src labels to x.

func (*Labels) Clone added in v1.85.0

func (x *Labels) Clone() *Labels

Clone returns a clone of x.

func (*Labels) Get added in v1.85.0

func (x *Labels) Get(name string) string

Get returns value for label with the given name.

func (*Labels) GetLabels added in v1.85.0

func (x *Labels) GetLabels() []prompbmarshal.Label

GetLabels returns the list of labels from x.

func (*Labels) InitFromMap added in v1.85.0

func (x *Labels) InitFromMap(m map[string]string)

InitFromMap initializes x from m.

func (*Labels) InternStrings added in v1.85.0

func (x *Labels) InternStrings()

InternStrings interns all the strings used in x labels.

func (*Labels) Len added in v1.85.0

func (x *Labels) Len() int

Len returns the number of labels in x.

func (*Labels) Less added in v1.85.0

func (x *Labels) Less(i, j int) bool

Less compares label names at i and j index.

func (*Labels) MarshalJSON added in v1.85.0

func (x *Labels) MarshalJSON() ([]byte, error)

MarshalJSON returns JSON representation for x.

func (*Labels) MarshalYAML added in v1.85.0

func (x *Labels) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler interface.

func (*Labels) RemoveDuplicates added in v1.85.0

func (x *Labels) RemoveDuplicates()

RemoveDuplicates removes labels with duplicate names.

func (*Labels) RemoveLabelsWithDoubleUnderscorePrefix added in v1.85.0

func (x *Labels) RemoveLabelsWithDoubleUnderscorePrefix()

RemoveLabelsWithDoubleUnderscorePrefix removes labels with "__" prefix from x.

func (*Labels) RemoveMetaLabels added in v1.85.0

func (x *Labels) RemoveMetaLabels()

RemoveMetaLabels removes all the `__meta_` labels from x.

See https://www.robustperception.io/life-of-a-label for details.

func (*Labels) Reset added in v1.85.0

func (x *Labels) Reset()

Reset resets x.

func (*Labels) Set added in v1.90.0

func (x *Labels) Set(name, value string)

Set label value for label with given name If the label with the given name doesn't exist, it adds as the new label

func (*Labels) Sort added in v1.85.0

func (x *Labels) Sort()

Sort sorts x labels in alphabetical order of their names.

func (*Labels) SortStable added in v1.85.0

func (x *Labels) SortStable()

SortStable sorts x labels in alphabetical order of their name using stable sort.

func (*Labels) String added in v1.85.0

func (x *Labels) String() string

String returns string representation of x.

func (*Labels) Swap added in v1.85.0

func (x *Labels) Swap(i, j int)

Swap swaps labels at i and j index.

func (*Labels) ToMap added in v1.85.0

func (x *Labels) ToMap() map[string]string

ToMap returns a map for the given labels x.

func (*Labels) UnmarshalJSON added in v1.85.0

func (x *Labels) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON from data.

func (*Labels) UnmarshalYAML added in v1.85.0

func (x *Labels) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler interface.

type LabelsCompressor added in v1.97.7

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

LabelsCompressor compresses []prompbmarshal.Label into short binary strings

func (*LabelsCompressor) Compress added in v1.97.7

func (lc *LabelsCompressor) Compress(dst []byte, labels []prompbmarshal.Label) []byte

Compress compresses labels, appends the compressed labels to dst and returns the result.

It is safe calling Compress from concurrent goroutines.

func (*LabelsCompressor) Decompress added in v1.97.7

func (lc *LabelsCompressor) Decompress(dst []prompbmarshal.Label, src []byte) []prompbmarshal.Label

Decompress decompresses src into []prompbmarshal.Label, appends it to dst and returns the result.

It is safe calling Decompress from concurrent goroutines.

func (*LabelsCompressor) ItemsCount added in v1.97.7

func (lc *LabelsCompressor) ItemsCount() uint64

ItemsCount returns the number of items in lc

func (*LabelsCompressor) SizeBytes added in v1.97.7

func (lc *LabelsCompressor) SizeBytes() uint64

SizeBytes returns the size of lc data in bytes

Jump to

Keyboard shortcuts

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