alerts

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package alerts manages Prometheus alert rules and Alertmanager routing for nSelf.

Index

Constants

View Source
const (
	SeverityP1 = "P1"
	SeverityP2 = "P2"
	SeverityP3 = "P3"
)

Severity levels for alert rules.

Variables

This section is empty.

Functions

func TestAlert

func TestAlert(ctx context.Context, alertName string, alertmanagerURL string) error

TestAlert fires a synthetic test alert by sending to Alertmanager's API.

Types

type AlertRule

type AlertRule struct {
	Name     string `json:"name"`
	Severity string `json:"severity"`
	Expr     string `json:"expr"`
	For      string `json:"for"`
	Summary  string `json:"summary"`
}

AlertRule describes a single Prometheus alert rule.

func DefaultRules

func DefaultRules() []AlertRule

DefaultRules returns the 16 default nSelf alert rules.

func List

func List(severity string) []AlertRule

List returns alert rules, optionally filtered by severity.

type Silence

type Silence struct {
	ID        string    `json:"id"`
	AlertName string    `json:"alert_name"`
	Reason    string    `json:"reason"`
	ExpiresAt time.Time `json:"expires_at"`
	CreatedAt time.Time `json:"created_at"`
}

Silence represents an active alert silence.

func CreateSilence

func CreateSilence(ctx context.Context, alertName, reason string, duration time.Duration, workdir string) (*Silence, error)

CreateSilence creates a silence for the given alert. It stores it locally and attempts to create it in Alertmanager if available.

Jump to

Keyboard shortcuts

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