alert

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package alert defines threshold alerts on event metrics — "fire when <event> count over the last N hours is above/below a threshold". The Server evaluates them on a schedule and delivers via webhooks; this package is the persisted rules + their runtime state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Event       string    `json:"event"`
	Op          string    `json:"op"` // "gt" | "lt"
	Threshold   float64   `json:"threshold"`
	WindowHours int       `json:"window_hours"`
	Enabled     bool      `json:"enabled"`
	Created     time.Time `json:"created"`
	LastChecked time.Time `json:"last_checked"`
	LastValue   float64   `json:"last_value"`
	LastFired   time.Time `json:"last_fired"`
}

Alert is one rule plus its last-evaluation state.

type Store

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

func Open

func Open(path string) (*Store, error)

func (*Store) Add

func (s *Store) Add(a Alert) (Alert, error)

func (*Store) Delete

func (s *Store) Delete(id string) error

func (*Store) List

func (s *Store) List() []Alert

func (*Store) SetChecked

func (s *Store) SetChecked(id string, value float64, fired bool, at time.Time)

SetChecked records an evaluation result (and a fire time, if it fired).

Jump to

Keyboard shortcuts

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