Documentation
¶
Index ¶
- Variables
- func ErrChannelNotFound(ch string) error
- func ErrChannelTypeNotSupported(chType string) error
- func MustInitFromViper()
- type Channel
- type ChannelType
- type DingTalkChannel
- type DingTalkConfig
- type DingTalkMarkdownFormatter
- type FlashDutyChannel
- type FlashDutyConfig
- type Formatter
- type Manager
- type Notification
- type PagerDutyChannel
- type PagerDutyConfig
- type Severity
- type SimpleTextFormatter
- type SmtpChannel
- type SmtpConfig
- type SmtpHtmlFormatter
- type TelegramChannel
- type TelegramConfig
- type TelegramMarkdownFormatter
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidNotification = errors.New("invalid notification")
)
Functions ¶
func ErrChannelNotFound ¶ added in v0.2.1
func ErrChannelTypeNotSupported ¶ added in v0.2.1
func MustInitFromViper ¶
func MustInitFromViper()
MustInitFromViper inits alert from viper settings or panic on error.
Types ¶
type Channel ¶ added in v0.2.1
type Channel interface {
Name() string
Type() ChannelType
Send(context.Context, *Notification) error
}
Notification channel interface.
type ChannelType ¶ added in v0.2.1
type ChannelType string
Notification channel type.
const ( ChannelTypeDingTalk ChannelType = "dingtalk" ChannelTypeTelegram ChannelType = "telegram" ChannelTypeSMTP ChannelType = "smtp" ChannelTypePagerDuty ChannelType = "pagerduty" ChannelTypeFlashDuty ChannelType = "flashduty" )
type DingTalkChannel ¶ added in v0.2.1
type DingTalkChannel struct {
*dingtalk.Robot
ID string // channel id
Config DingTalkConfig // channel config
Formatter Formatter // message formatter
}
DingTalkChannel DingTalk notification channel
func NewDingTalkChannel ¶ added in v0.2.1
func NewDingTalkChannel(chID string, fmt Formatter, conf DingTalkConfig) *DingTalkChannel
func (*DingTalkChannel) Name ¶ added in v0.2.1
func (dtc *DingTalkChannel) Name() string
func (*DingTalkChannel) Send ¶ added in v0.2.1
func (dtc *DingTalkChannel) Send(ctx context.Context, note *Notification) error
func (*DingTalkChannel) Type ¶ added in v0.2.1
func (dtc *DingTalkChannel) Type() ChannelType
type DingTalkConfig ¶
type DingTalkMarkdownFormatter ¶ added in v0.2.1
type DingTalkMarkdownFormatter struct {
// contains filtered or unexported fields
}
func NewDingtalkMarkdownFormatter ¶ added in v0.2.1
func NewDingtalkMarkdownFormatter(tags, mentions []string) (*DingTalkMarkdownFormatter, error)
func (DingTalkMarkdownFormatter) Format ¶ added in v0.2.1
func (f DingTalkMarkdownFormatter) Format(note *Notification) (string, error)
type FlashDutyChannel ¶ added in v0.6.7
type FlashDutyChannel struct {
*flashduty.Robot
ID string // the identifier of the channel
Config FlashDutyConfig // the configuration for the FlashDuty channel
}
FlashDutyChannel represents a FlashDuty notification channel.
func NewFlashDutyChannel ¶ added in v0.6.7
func NewFlashDutyChannel(chID string, conf FlashDutyConfig) *FlashDutyChannel
NewFlashDutyChannel creates a new FlashDuty channel with the given ID and configuration
func (*FlashDutyChannel) Name ¶ added in v0.6.7
func (c *FlashDutyChannel) Name() string
Name returns the ID of the channel
func (*FlashDutyChannel) Send ¶ added in v0.6.7
func (c *FlashDutyChannel) Send(ctx context.Context, note *Notification) error
Send sends notification using the FlashDuty channel.
func (*FlashDutyChannel) Type ¶ added in v0.6.7
func (c *FlashDutyChannel) Type() ChannelType
Type returns the type of the channel, which is FlashDuty
type FlashDutyConfig ¶ added in v0.6.7
type Formatter ¶ added in v0.2.1
type Formatter interface {
Format(note *Notification) (string, error)
}
Formatter defines how messages are formatted.
type Manager ¶ added in v0.2.1
type Manager struct {
// contains filtered or unexported fields
}
func DefaultManager ¶ added in v0.2.1
func DefaultManager() *Manager
func NewManager ¶ added in v0.2.1
func NewManager() *Manager
type Notification ¶ added in v0.2.1
type Notification struct {
Title string // message title
Content interface{} // message content
Severity Severity // severity level
}
Notification represents core information for an alert.
type PagerDutyChannel ¶ added in v0.3.0
type PagerDutyChannel struct {
*pagerduty.Client
ID string // the identifier of the channel
Config PagerDutyConfig // the configuration for the PagerDuty channel
// contains filtered or unexported fields
}
PagerDutyChannel represents a PagerDuty notification channel.
func NewPagerDutyChannel ¶ added in v0.3.0
func NewPagerDutyChannel(chID string, tags []string, conf PagerDutyConfig) *PagerDutyChannel
NewPagerDutyChannel creates a new PagerDuty channel with the given ID and configuration
func (*PagerDutyChannel) Name ¶ added in v0.3.0
func (c *PagerDutyChannel) Name() string
Name returns the ID of the channel
func (*PagerDutyChannel) Send ¶ added in v0.3.0
func (c *PagerDutyChannel) Send(ctx context.Context, note *Notification) error
Send sends notification using the PagerDuty channel.
func (*PagerDutyChannel) Type ¶ added in v0.3.0
func (c *PagerDutyChannel) Type() ChannelType
Type returns the type of the channel, which is PagerDuty
type PagerDutyConfig ¶ added in v0.3.0
type SimpleTextFormatter ¶ added in v0.2.1
type SimpleTextFormatter struct {
// contains filtered or unexported fields
}
func NewSimpleTextFormatter ¶ added in v0.2.1
func NewSimpleTextFormatter(tags, mentions []string) (fmt *SimpleTextFormatter, err error)
func (*SimpleTextFormatter) Format ¶ added in v0.2.1
func (f *SimpleTextFormatter) Format(note *Notification) (string, error)
type SmtpChannel ¶ added in v0.2.1
type SmtpChannel struct {
Formatter Formatter // Formatter is used to format the notification message
ID string // ID is the identifier of the channel
Config SmtpConfig // Config contains the configuration for the SMTP server
}
SmtpChannel represents a SMTP email notification channel
func NewSmtpChannel ¶ added in v0.2.1
func NewSmtpChannel(chID string, fmtter Formatter, conf SmtpConfig) *SmtpChannel
NewSmtpChannel creates a new SMTP channel with the given ID, formatter, and configuration
func (*SmtpChannel) Name ¶ added in v0.2.1
func (c *SmtpChannel) Name() string
Name returns the ID of the channel
func (*SmtpChannel) Send ¶ added in v0.2.1
func (c *SmtpChannel) Send(ctx context.Context, note *Notification) error
Send sends a notification using the SMTP channel
func (*SmtpChannel) SendProtoMsg ¶ added in v0.3.0
func (c *SmtpChannel) SendProtoMsg(ctx context.Context, msg string) error
SendProtoMsg sends protocol message using the SMTP channel. Callers should provide a context with a deadline to bound the entire session.
func (*SmtpChannel) Type ¶ added in v0.2.1
func (c *SmtpChannel) Type() ChannelType
Type returns the type of the channel, which is SMTP
type SmtpConfig ¶ added in v0.2.1
type SmtpHtmlFormatter ¶ added in v0.2.1
type SmtpHtmlFormatter struct {
// contains filtered or unexported fields
}
func NewSmtpHtmlFormatter ¶ added in v0.2.1
func NewSmtpHtmlFormatter( conf SmtpConfig, tags []string) (f *SmtpHtmlFormatter, err error)
func (*SmtpHtmlFormatter) Format ¶ added in v0.2.1
func (f *SmtpHtmlFormatter) Format(note *Notification) (msg string, err error)
Format builds an HTML email and rejects titles containing CR or LF to prevent the title from introducing additional email headers.
type TelegramChannel ¶ added in v0.2.1
type TelegramChannel struct {
*bot.Bot
Formatter Formatter // message formatter
ID string // channel id
Config TelegramConfig // channel config
}
TelegramChannel Telegram notification channel
func NewTelegramChannel ¶ added in v0.2.1
func NewTelegramChannel(chID string, fmt Formatter, conf TelegramConfig) (*TelegramChannel, error)
func (*TelegramChannel) Name ¶ added in v0.2.1
func (tc *TelegramChannel) Name() string
func (*TelegramChannel) Send ¶ added in v0.2.1
func (tc *TelegramChannel) Send(ctx context.Context, note *Notification) error
func (*TelegramChannel) Type ¶ added in v0.2.1
func (tc *TelegramChannel) Type() ChannelType
type TelegramConfig ¶ added in v0.2.1
type TelegramMarkdownFormatter ¶ added in v0.2.1
type TelegramMarkdownFormatter struct {
// contains filtered or unexported fields
}
func NewTelegramMarkdownFormatter ¶ added in v0.2.1
func NewTelegramMarkdownFormatter(tags, atUsers []string) (f *TelegramMarkdownFormatter, err error)
func (*TelegramMarkdownFormatter) Format ¶ added in v0.2.1
func (f *TelegramMarkdownFormatter) Format(note *Notification) (string, error)