amstate

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Stream = "/alertmanager"
)

Variables

This section is empty.

Functions

func HasAlertWithId

func HasAlertWithId(id string, alerts []Alert) bool

func NewAlertId

func NewAlertId() string

func NewHttpMonitorId

func NewHttpMonitorId() string

Types

type Alert

type Alert struct {
	Id        string    `json:"alert_key"` // name in JSON for backwards compat
	Subject   string    `json:"subject"`   // same type of error should always have same subject
	Details   string    `json:"details"`
	Timestamp time.Time `json:"timestamp"`
}

func FindAlertWithSubject

func FindAlertWithSubject(subject string, alerts []Alert) *Alert

func GetUnnoticedAlerts

func GetUnnoticedAlerts(alerts []Alert, now time.Time) []Alert

unnoticed = not acked within 4 hours

type App

type App struct {
	State  *Store
	Reader *ehreader.Reader
	Writer ehclient.Writer
	Logger *log.Logger
}

func LoadUntilRealtime

func LoadUntilRealtime(
	ctx context.Context,
	tenantCtx *ehreader.TenantCtxWithSnapshots,
	logger *log.Logger,
) (*App, error)

func (*App) AppendAfter

func (a *App) AppendAfter(ctx context.Context, cur ehclient.Cursor, events ...ehevent.Event) error

helper

type DeadMansSwitch

type DeadMansSwitch struct {
	Subject string    `json:"subject"`
	Ttl     time.Time `json:"ttl"`
}

func FindDeadMansSwitchWithSubject

func FindDeadMansSwitchWithSubject(subject string, dmss []DeadMansSwitch) *DeadMansSwitch

func GetExpiredDeadMansSwitches

func GetExpiredDeadMansSwitches(switches []DeadMansSwitch, now time.Time) []DeadMansSwitch

type HttpMonitor

type HttpMonitor struct {
	Id      string    `json:"id"`
	Created time.Time `json:"created"`
	Enabled bool      `json:"enabled"`
	Url     string    `json:"url"`
	Find    string    `json:"find"`
}

func EnabledHttpMonitors added in v1.0.1

func EnabledHttpMonitors(monitors []HttpMonitor) []HttpMonitor

func FindHttpMonitorWithId

func FindHttpMonitorWithId(id string, monitors []HttpMonitor) *HttpMonitor

type Store

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

func New

func New(tenant ehreader.Tenant, logger *log.Logger) *Store

func (*Store) ActiveAlerts

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

func (*Store) DeadMansSwitches

func (s *Store) DeadMansSwitches() []DeadMansSwitch

func (*Store) GetEventTypes

func (s *Store) GetEventTypes() ehevent.Allocators

func (*Store) HttpMonitors

func (s *Store) HttpMonitors() []HttpMonitor

func (*Store) InstallSnapshot

func (s *Store) InstallSnapshot(snap *ehreader.Snapshot) error

func (*Store) LastUnnoticedAlertsNotified

func (s *Store) LastUnnoticedAlertsNotified() time.Time

func (*Store) ProcessEvents

func (s *Store) ProcessEvents(_ context.Context, processAndCommit ehreader.EventProcessorHandler) error

func (*Store) Snapshot

func (s *Store) Snapshot() (*ehreader.Snapshot, error)

func (*Store) Version

func (s *Store) Version() ehclient.Cursor

Jump to

Keyboard shortcuts

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