templating

package
v1.40.4 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// DefaultSeparator is the default separation character to use when separating template parts.
	DefaultSeparator = "."
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine uses a Matcher to retrieve the appropriate template and applies the template to the input string

func NewEngine

func NewEngine(joiner string, defaultTemplate *Template, templates []string) (*Engine, error)

NewEngine creates a new templating engine

func (*Engine) Apply

func (e *Engine) Apply(line string) (measurementName string, tags map[string]string, field string, err error)

Apply extracts the template fields from the given line and returns the measurement name, tags and field name

type Template

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

Template represents a pattern and tags to map a metric string to an influxdb Point

func NewDefaultTemplateWithPattern

func NewDefaultTemplateWithPattern(pattern string) (*Template, error)

func NewTemplate

func NewTemplate(separator, pattern string, defaultTags map[string]string) (*Template, error)

NewTemplate returns a new template ensuring it has a measurement specified.

func (*Template) Apply

func (t *Template) Apply(line string, joiner string) (measurementName string, tags map[string]string, field string, err error)

Apply extracts the template fields from the given line and returns the measurement name, tags and field name

Jump to

Keyboard shortcuts

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