alertmanager

package
v1.28.4 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: Apache-2.0, MIT Imports: 45 Imported by: 0

Documentation

Overview

Package alertmanager provides a framework for monitoring and alerting within the Curio project. It supports dynamic plugin integration for alert notifications, allowing for flexible and extensible alerting mechanisms.

Implementing a New Plugin:

1. Define a struct that implements the Plugin interface, which includes the SendAlert method for dispatching alerts. 2. Implement the SendAlert method to handle the alert logic specific to your plugin. 3. Provide a constructor function for your plugin to facilitate its configuration and initialization. 4. Register your plugin in the LoadAlertPlugins function, which dynamically loads plugins based on the CurioAlertingConfig.

Plugin Configuration:

Plugins are configured through the config.CurioAlertingConfig struct. Each plugin can have its own configuration section within this struct, enabling or disabling the plugin and setting plugin-specific parameters.

Example:

```go type MyPlugin struct{}

func (p *MyPlugin) SendAlert(data *plugin.AlertPayload) error {
	// Plugin-specific alert sending logic
	return nil
}

func NewMyPlugin() *MyPlugin {
	return &MyPlugin{}
}

func LoadAlertPlugins(cfg config.CurioAlertingConfig) []plugin.Plugin {
	var plugins []plugin.Plugin
	if cfg.MyPlugin.Enabled {
		plugins = append(plugins, NewMyPlugin())
	}
	return plugins
}

``` This package leverages the CurioAlertingConfig for plugin configuration, enabling a modular approach to adding or removing alerting capabilities as required.

Index

Constants

View Source
const AlertManagerInterval = 5 * time.Minute
View Source
const FullAlertInterval = 30 * time.Minute

Variables

View Source
var (
	AlertFuncs      map[AlertName]AlertFunc
	PingHealthFuncs map[AlertName]AlertFunc
)

Functions

func AlertSource added in v1.28.3

func AlertSource(clusterName string) string

AlertSource returns the configured cluster identifier, falling back to the hostname of the node executing the alert delivery.

func NowCheck added in v1.23.1

func NowCheck(al *alerts)

Types

type AddrInfo added in v1.28.1

type AddrInfo struct {
	ID    string   `json:"ID"`
	Addrs []string `json:"Addrs"`
}
type Advertisement struct {
	Slash string `json:"/"`
}

type AlertAPI

type AlertAPI interface {
	ctladdr.NodeApi
	ChainReadObj(context.Context, cid.Cid) ([]byte, error)
	ChainHasObj(context.Context, cid.Cid) (bool, error)
	ChainPutObj(context.Context, blocks.Block) error
	ChainHead(context.Context) (*types.TipSet, error)
	StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (api.MinerInfo, error)
	StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
	StateMinerPartitions(context.Context, address.Address, uint64, types.TipSetKey) ([]api.Partition, error)
	StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error)
}

type AlertFunc added in v1.23.1

type AlertFunc func(al *alerts)

type AlertName added in v1.28.1

type AlertName string
const (
	Name_BalanceCheck          AlertName = "Balance Check"
	Name_TaskFailures          AlertName = "TaskFailures"
	Name_PDPTaskFailures       AlertName = "PDPTaskFailures"
	Name_PermanentStorageSpace AlertName = "PermanentStorageSpace"
	Name_WindowPost            AlertName = "WindowPost"
	Name_WinningPost           AlertName = "WinningPost"
	Name_NowCheck              AlertName = "NowCheck"
	Name_ChainSync             AlertName = "ChainSync"
	Name_MissingSectors        AlertName = "MissingSectors"
	Name_PendingMessages       AlertName = "PendingMessages"
	Name_IPNISync              AlertName = "IPNISync"
	Name_PDPKeyConfigured      AlertName = "PDPKeyConfigured"
)

type AlertNow added in v1.23.1

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

func NewAlertNow added in v1.23.1

func NewAlertNow(db *harmonydb.DB, name string) *AlertNow

func (*AlertNow) AddAlert added in v1.23.1

func (n *AlertNow) AddAlert(msg string)

type AlertTask

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

func NewAlertTask

func NewAlertTask(
	api AlertAPI, db *harmonydb.DB, alertingCfg config.CurioAlertingConfig) *AlertTask

func (*AlertTask) Adder

func (a *AlertTask) Adder(taskFunc harmonytask.AddTaskFunc)

func (*AlertTask) CanAccept

func (a *AlertTask) CanAccept(ids []harmonytask.TaskID, engine *harmonytask.TaskEngine) ([]harmonytask.TaskID, error)

func (*AlertTask) Do

func (a *AlertTask) Do(ctx context.Context, taskID harmonytask.TaskID, stillOwned func() bool) (done bool, err error)

func (*AlertTask) Problems added in v1.28.1

func (a *AlertTask) Problems() bool

Problems returns the ping-relevant alert results from the most recent AlertTask run (ChainSync, PermanentStorageSpace, Balance Check). Returns nil before the first run — the node is assumed healthy until the first periodic check completes.

func (*AlertTask) TypeDetails

func (a *AlertTask) TypeDetails() harmonytask.TaskTypeDetails

type ParsedResponse added in v1.28.1

type ParsedResponse struct {
	AddrInfo              AddrInfo       `json:"AddrInfo"`
	LastAdvertisement     Advertisement  `json:"LastAdvertisement"`
	LastAdvertisementTime time.Time      `json:"LastAdvertisementTime"`
	Publisher             AddrInfo       `json:"Publisher"`
	ExtendedProviders     map[string]any `json:"ExtendedProviders"`
	FrozenAt              string         `json:"FrozenAt"`
	LastError             string         `json:"LastError"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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