alert

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package alert 提供 webhook 告警通知功能。

Index

Constants

View Source
const (
	EventQuotaExceeded = "quota_exceeded" // token 配额超限
	EventRateLimited   = "rate_limited"   // 请求频率超限
	EventNodeDown      = "node_down"      // 集群节点下线
	EventNodeRecovered = "node_recovered" // 集群节点恢复
)

告警事件类型常量

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Kind    string            `json:"kind"`             // 事件类型(见上方常量)
	At      time.Time         `json:"at"`               // 事件发生时间
	Message string            `json:"message"`          // 可读描述
	Labels  map[string]string `json:"labels,omitempty"` // 附加标签(user_id 等)
}

Event 告警事件

type Notifier

type Notifier struct {
	// contains filtered or unexported fields
}

Notifier 向 webhook URL 异步发送告警事件。 webhookURL 为空时所有操作均为 no-op。

func NewNotifier

func NewNotifier(logger *zap.Logger, webhookURL string) *Notifier

NewNotifier 创建 Notifier。 webhookURL 为空时返回静默(no-op)的 Notifier。

func (*Notifier) Notify

func (n *Notifier) Notify(evt Event)

Notify 异步发送告警(非阻塞)。 若 webhookURL 为空,则不做任何事。

Jump to

Keyboard shortcuts

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