template

package
v0.0.0-...-f8c6d31 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlertTemplateData

func AlertTemplateData(labels, externalLabels map[string]string, externalURL string, value float64) interface{}

AlertTemplateData returns the interface to be used in expanding the template.

Types

type Expander

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

Expander executes templates in text or HTML mode with a common set of Prometheus template functions.

func NewTemplateExpander

func NewTemplateExpander(
	ctx context.Context,
	text string,
	name string,
	data interface{},
	timestamp model.Time,
	queryFunc QueryFunc,
	externalURL *url.URL,
	options []string,
) *Expander

NewTemplateExpander returns a template expander ready to use.

func (Expander) Expand

func (te Expander) Expand() (result string, resultErr error)

Expand expands a template in text (non-HTML) mode.

func (Expander) ExpandHTML

func (te Expander) ExpandHTML(templateFiles []string) (result string, resultErr error)

ExpandHTML expands a template with HTML escaping, with templates read from the given files.

func (Expander) Funcs

func (te Expander) Funcs(fm text_template.FuncMap)

Funcs adds the functions in fm to the Expander's function map. Existing functions will be overwritten in case of conflict.

func (Expander) ParseTest

func (te Expander) ParseTest() error

ParseTest parses the templates and returns the error if any.

type QueryFunc

type QueryFunc func(context.Context, string, time.Time) (promql.Vector, error)

QueryFunc executes a PromQL query at the given time.

Jump to

Keyboard shortcuts

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