alertmanager: Index | Files

package template

import ""


Package Files



var DefaultFuncs = FuncMap{
    "toUpper": strings.ToUpper,
    "toLower": strings.ToLower,
    "title":   strings.Title,

    "join": func(sep string, s []string) string {
        return strings.Join(s, sep)
    "match": regexp.MatchString,
    "safeHtml": func(text string) tmplhtml.HTML {
        return tmplhtml.HTML(text)
    "reReplaceAll": func(pattern, repl, text string) string {
        re := regexp.MustCompile(pattern)
        return re.ReplaceAllString(text, repl)
    "stringSlice": func(s ...string) []string {
        return s

type Alert Uses

type Alert struct {
    Status       string    `json:"status"`
    Labels       KV        `json:"labels"`
    Annotations  KV        `json:"annotations"`
    StartsAt     time.Time `json:"startsAt"`
    EndsAt       time.Time `json:"endsAt"`
    GeneratorURL string    `json:"generatorURL"`
    Fingerprint  string    `json:"fingerprint"`

Alert holds one alert for notification templates.

type Alerts Uses

type Alerts []Alert

Alerts is a list of Alert objects.

func (Alerts) Firing Uses

func (as Alerts) Firing() []Alert

Firing returns the subset of alerts that are firing.

func (Alerts) Resolved Uses

func (as Alerts) Resolved() []Alert

Resolved returns the subset of alerts that are resolved.

type Data Uses

type Data struct {
    Receiver string `json:"receiver"`
    Status   string `json:"status"`
    Alerts   Alerts `json:"alerts"`

    GroupLabels       KV  `json:"groupLabels"`
    CommonLabels      KV  `json:"commonLabels"`
    CommonAnnotations KV  `json:"commonAnnotations"`

    ExternalURL string `json:"externalURL"`

Data is the data passed to notification templates and webhook pushes.

End-users should not be exposed to Go's type system, as this will confuse them and prevent simple things like simple equality checks to fail. Map everything to float64/string.

type FuncMap Uses

type FuncMap map[string]interface{}

type KV Uses

type KV map[string]string

KV is a set of key/value string pairs.

func (KV) Names Uses

func (kv KV) Names() []string

Names returns the names of the label names in the LabelSet.

func (KV) Remove Uses

func (kv KV) Remove(keys []string) KV

Remove returns a copy of the key/value set without the given keys.

func (KV) SortedPairs Uses

func (kv KV) SortedPairs() Pairs

SortedPairs returns a sorted list of key/value pairs.

func (KV) Values Uses

func (kv KV) Values() []string

Values returns a list of the values in the LabelSet.

type Pair Uses

type Pair struct {
    Name, Value string

Pair is a key/value string pair.

type Pairs Uses

type Pairs []Pair

Pairs is a list of key/value string pairs.

func (Pairs) Names Uses

func (ps Pairs) Names() []string

Names returns a list of names of the pairs.

func (Pairs) Values Uses

func (ps Pairs) Values() []string

Values returns a list of values of the pairs.

type Template Uses

type Template struct {
    ExternalURL *url.URL
    // contains filtered or unexported fields

Template bundles a text and a html template instance.

func FromGlobs Uses

func FromGlobs(paths ...string) (*Template, error)

FromGlobs calls ParseGlob on all path globs provided and returns the resulting Template.

func (*Template) Data Uses

func (t *Template) Data(recv string, groupLabels model.LabelSet, alerts ...*types.Alert) *Data

Data assembles data for template expansion.

func (*Template) ExecuteHTMLString Uses

func (t *Template) ExecuteHTMLString(html string, data interface{}) (string, error)

ExecuteHTMLString needs a meaningful doc comment (TODO(fabxc)).

func (*Template) ExecuteTextString Uses

func (t *Template) ExecuteTextString(text string, data interface{}) (string, error)

ExecuteTextString needs a meaningful doc comment (TODO(fabxc)).

Package template imports 13 packages (graph) and is imported by 132 packages. Updated 2020-08-13. Refresh now. Tools for package owners.