Documentation
¶
Index ¶
- func ExecuteTextString(text string, data interface{}) (string, error)
- func LoadDefaultTemplate(tmplLang string) error
- func LoadTemplate(tmplDir, tmplName, tmplDefault, tmplLang string) error
- type Alert
- type AlertmanagerWebhookMessage
- func (m *AlertmanagerWebhookMessage) RenderTmpl(channel string, tmplName string) (string, error)
- func (m *AlertmanagerWebhookMessage) SetMessageAt() *AlertmanagerWebhookMessage
- func (m *AlertmanagerWebhookMessage) SetSignature(s string) *AlertmanagerWebhookMessage
- func (m *AlertmanagerWebhookMessage) ToPayload(channel string, raw []byte) (*models.Payload, error)
- type Alerts
- type KV
- type Pair
- type Pairs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteTextString ¶
func LoadDefaultTemplate ¶ added in v1.0.1
LoadDefaultTemplate set default for the package level variables: promMsgTemplate and promMsgTemplatesMap.
func LoadTemplate ¶ added in v1.0.1
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
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 (m *AlertmanagerWebhookMessage) SetMessageAt() *AlertmanagerWebhookMessage
func (*AlertmanagerWebhookMessage) SetSignature ¶
func (m *AlertmanagerWebhookMessage) SetSignature(s string) *AlertmanagerWebhookMessage
type Alerts ¶
type Alerts []Alert
Click to show internal directories.
Click to hide internal directories.