utils

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTimeFieldWithRange added in v0.11.0

func AddTimeFieldWithRange(expr string, timeRange backend.TimeRange) string

AddTimeFieldWithRange adds time field with range to the query

func CalculateStep added in v0.8.0

func CalculateStep(minInterval time.Duration, timeRange backend.TimeRange, maxDataPoints int64) time.Duration

CalculateStep calculates step by provided max datapoints and timerange

func GetIntervalFrom added in v0.8.0

func GetIntervalFrom(dsInterval, queryInterval string, queryIntervalMS int64, defaultInterval time.Duration) (time.Duration, error)

GetIntervalFrom returns the minimum interval. dsInterval is the string representation of data source min interval, if configured. queryInterval is the string representation of query interval (min interval), e.g. "10ms" or "10s". queryIntervalMS is a pre-calculated numeric representation of the query interval in milliseconds.

func GetTime

func GetTime(s string) (time.Time, error)

GetTime returns time from the given string.

func ParseDuration

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

ParseDuration parses duration string in Prometheus format

func ParseTime

func ParseTime(s string) (float64, error)

ParseTime parses time s in different formats.

See https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#timestamp-formats

It returns unix timestamp in seconds.

func ParseTimeAt

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

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

See https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#timestamp-formats

It returns unix timestamp in seconds.

func ReplaceTemplateVariable added in v0.5.0

func ReplaceTemplateVariable(expr string, interval int64, timeRange backend.TimeRange) string

ReplaceTemplateVariable get query and use it expression to remove grafana template variables with

func WithIntervalVariable added in v0.8.0

func WithIntervalVariable(expr string) bool

WithIntervalVariable checks if the expression contains interval variable

Types

type StreamField added in v0.16.1

type StreamField struct {
	Label string
	Value string
}

StreamField represents the label values pair of the _stream fields in the log struct

func ParseStreamFields added in v0.16.1

func ParseStreamFields(streamFields string) ([]StreamField, error)

ParseStreamFields collect labels values pair from the _stream field

Jump to

Keyboard shortcuts

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