parser

package
v1.76.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWhenExactlyOneOperator = errors.New("when: exactly one operator is allowed; quote the value if it must contain operator characters")

Functions

func MapLabelPaths

func MapLabelPaths(labels []string, f func([]string) string) ([]string, error)

MapLabelPaths parses each dot-prefixed label path and applies f to the segments slice.

func MatchMustacheGroup

func MatchMustacheGroup(s string) (string, bool)

MatchMustacheGroup extracts a regex capture group name from a mustache template. example: `{{ grp }}` → ("grp", true) example: `literal` → ("", false)

func MatchMustachePath

func MatchMustachePath(s string) (string, bool)

MatchMustachePath extracts the inner path from a mustache template. example: `{{ .foo.bar }}` → (".foo.bar", true) example: `plain` → ("", false)

func ParseLabelPath

func ParseLabelPath(path string) ([]string, error)

ParseLabelPath splits a dot-prefixed label path into segments. example: `.foo.bar` → ["foo", "bar"] example: `.msg."a-b".level` → ["msg", "a-b", "level"] example: `.k."a\"b"` → ["k", `a"b`]

func PathSegmentsToVRLArray

func PathSegmentsToVRLArray(segments []string) string

PathSegmentsToVRLArray formats segments as a VRL array literal.

func PathSegmentsToVRLDotPath

func PathSegmentsToVRLDotPath(segments []string) string

PathSegmentsToVRLDotPath formats segments as a VRL dot-notation path. Bare identifiers stay unquoted, special characters get quoted. example: ["foo", "bar"] → `.foo.bar` example: ["msg", "a-b"] → `.msg."a-b"`

func SinkKeysFromVRLPaths

func SinkKeysFromVRLPaths(paths []string) ([]string, error)

SinkKeysFromVRLPaths returns each path as a VRL dot path without the leading dot (for loglabels drop prefixes; same rule as addLabels sink keys).

func VRLRegexFindComparisonOp

func VRLRegexFindComparisonOp(op WhenOp) (string, error)

VRLRegexFindComparisonOp maps =~ / !=~ to the equality operator used in generated VRL for regex match vs non-match on the extracted string.

func ValidateWhenRegexExpr

func ValidateWhenRegexExpr(we *WhenExpr) error

ValidateWhenRegexExpr compiles WhenExpr.Value for =~ / !=~. Invalid patterns must be rejected when building config so Vector does not fail at runtime.

Types

type WhenExpr

type WhenExpr struct {
	LeftPath     string
	LeftPathSegs []string
	Op           WhenOp
	Value        string
}

func ParseWhen

func ParseWhen(s string) (*WhenExpr, error)

type WhenOp

type WhenOp string
const (
	WhenEQ        WhenOp = "=="
	WhenNE        WhenOp = "!="
	WhenRe        WhenOp = "=~"
	WhenNRe       WhenOp = "!=~"
	WhenExists    WhenOp = "exists"
	WhenNotExists WhenOp = "notexists"
)

Jump to

Keyboard shortcuts

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