models

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteTextString

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

func LoadDefaultTemplate added in v1.0.1

func LoadDefaultTemplate(tmplLang string) error

LoadDefaultTemplate set default for the package level variables: promMsgTemplate and promMsgTemplatesMap.

func LoadTemplate added in v1.0.1

func LoadTemplate(tmplDir, tmplName, tmplDefault, tmplLang string) error

LoadTemplate loads external templates from specified template dir.

Types

type Alert

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"`
}

func (*Alert) UnmarshalJSON added in v1.1.6

func (alert *Alert) UnmarshalJSON(data []byte) error

type AlertmanagerWebhookMessage

type AlertmanagerWebhookMessage struct {
	Version         string           `json:"version"`
	GroupKey        *json.RawMessage `json:"groupKey"`
	TruncatedAlerts int              `json:"truncatedAlerts"`

	Status            string `json:"status"`
	Receiver          string `json:"receiver"`
	Alerts            Alerts `json:"alerts"`
	GroupLabels       KV     `json:"groupLabels"`
	CommonLabels      KV     `json:"commonLabels"`
	CommonAnnotations KV     `json:"commonAnnotations"`
	ExternalURL       string `json:"externalURL"`

	// extra fields added by us
	MessageAt time.Time `json:"messageAt"` // the time the webhook message was received
	Signature string    `json:"signature"` // 签名,如发送短信时出现在内容最前面【】
}

AlertManagerWebhookMessage holds data that alertmanager passed to webhook server. https://pkg.go.dev/github.com/prometheus/alertmanager/template#Data already defines a struct type, but here we re-defined it, cause we will fill extra fields into it.

func (*AlertmanagerWebhookMessage) RenderTmpl

func (m *AlertmanagerWebhookMessage) RenderTmpl(channel string, tmplName string) (string, error)

func (*AlertmanagerWebhookMessage) SetMessageAt

func (*AlertmanagerWebhookMessage) SetSignature

func (*AlertmanagerWebhookMessage) ToPayload

func (m *AlertmanagerWebhookMessage) ToPayload(channel string, raw []byte) *models.Payload

type Alerts

type Alerts []Alert

func (Alerts) Firing

func (as Alerts) Firing() []Alert

Firing returns the subset of alerts that are firing.

func (Alerts) Resolved

func (as Alerts) Resolved() []Alert

Resolved returns the subset of alerts that are resolved.

type KV

type KV map[string]string

KV is a set of key/value string pairs.

func (KV) Names

func (kv KV) Names() []string

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

func (KV) Remove

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

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

func (KV) SortedPairs

func (kv KV) SortedPairs() Pairs

SortedPairs returns a sorted list of key/value pairs.

func (KV) Values

func (kv KV) Values() []string

Values returns a list of the values in the LabelSet.

type Pair

type Pair struct {
	Name, Value string
}

Pair is a key/value string pair.

type Pairs

type Pairs []Pair

Pairs is a list of key/value string pairs.

func (Pairs) Names

func (ps Pairs) Names() []string

Names returns a list of names of the pairs.

func (Pairs) Values

func (ps Pairs) Values() []string

Values returns a list of values of the pairs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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