alerting

package
v0.25.3 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alerting

type Alerting struct {
	ModuleName string                `mapstructure:"module-name" yaml:"module-name" json:"moduleName"` // 模块名称
	Enabled    bool                  `mapstructure:"enabled" yaml:"enabled" json:"enabled"`            // 是否启用告警
	Webhooks   []string              `mapstructure:"webhooks" yaml:"webhooks" json:"webhooks"`         // Webhook列表
	Channels   []NotificationChannel `mapstructure:"channels" yaml:"channels" json:"channels"`         // 通知渠道
}

Alerting 告警配置

func Default

func Default() *Alerting

Default 创建默认告警配置

func (*Alerting) AddChannel

func (a *Alerting) AddChannel(name, channelType string, settings map[string]string) *Alerting

AddChannel 添加通知渠道

func (*Alerting) AddEmailChannel

func (a *Alerting) AddEmailChannel(name, smtpHost, smtpPort, username, password string, recipients []string) *Alerting

AddEmailChannel 添加邮件通知渠道

func (*Alerting) AddSlackChannel

func (a *Alerting) AddSlackChannel(name, webhook, channel string) *Alerting

AddSlackChannel 添加Slack通知渠道

func (*Alerting) AddWebhook

func (a *Alerting) AddWebhook(webhook string) *Alerting

AddWebhook 添加Webhook

func (*Alerting) Clone

func (a *Alerting) Clone() internal.Configurable

Clone 返回配置的副本

func (*Alerting) Disable

func (a *Alerting) Disable() *Alerting

Disable 禁用告警

func (*Alerting) Enable

func (a *Alerting) Enable() *Alerting

Enable 启用告警

func (*Alerting) Get

func (a *Alerting) Get() interface{}

Get 返回配置接口

func (*Alerting) IsEnabled

func (a *Alerting) IsEnabled() bool

IsEnabled 检查是否启用

func (*Alerting) Set

func (a *Alerting) Set(data interface{})

Set 设置配置数据

func (*Alerting) Validate

func (a *Alerting) Validate() error

Validate 验证配置

func (*Alerting) WithChannels

func (a *Alerting) WithChannels(channels []NotificationChannel) *Alerting

WithChannels 设置通知渠道列表

func (*Alerting) WithWebhooks

func (a *Alerting) WithWebhooks(webhooks []string) *Alerting

WithWebhooks 设置Webhook列表

type NotificationChannel

type NotificationChannel struct {
	Name     string            `mapstructure:"name" yaml:"name" json:"name"`             // 渠道名称
	Type     string            `mapstructure:"type" yaml:"type" json:"type"`             // 渠道类型 (slack, email, webhook)
	Settings map[string]string `mapstructure:"settings" yaml:"settings" json:"settings"` // 渠道设置
}

NotificationChannel 通知渠道配置

Jump to

Keyboard shortcuts

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