alertmanager

package
v1.24.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0, MIT Imports: 31 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 AlertMangerInterval = time.Hour

Variables

View Source
var AlertFuncs = []AlertFunc{
	balanceCheck,
	taskFailureCheck,
	permanentStorageCheck,
	wdPostCheck,
	wnPostCheck,
	NowCheck,
	chainSyncCheck,
}

Functions

func NowCheck added in v1.23.1

func NowCheck(al *alerts)

Types

type AlertAPI

type AlertAPI interface {
	ctladdr.NodeApi
	ChainHead(context.Context) (*types.TipSet, error)
	ChainGetTipSet(context.Context, types.TipSetKey) (*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)
}

type AlertFunc added in v1.23.1

type AlertFunc func(al *alerts)

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, al *curioalerting.AlertingSystem) *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(taskID harmonytask.TaskID, stillOwned func() bool) (done bool, err error)

func (*AlertTask) TypeDetails

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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