trigger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package trigger ingests incidents (Alertmanager/VMAlert webhooks) and decides, per the configured policy, which ones start an investigation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAlertmanager

func ParseAlertmanager(r io.Reader) ([]config.Incident, error)

ParseAlertmanager reads an Alertmanager webhook body into incidents. Both firing and resolved alerts are returned, each tagged with its Status (the caller routes resolved ones to the outcome ledger). "environment" is taken from the label of the same name, falling back to "env".

Types

type Decision

type Decision struct {
	Investigate bool
	Reason      string
}

Decision is the outcome of evaluating an incident against the trigger policy.

type Deduper

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

Deduper suppresses repeated investigations of the same still-firing alert within a time window. Safe for concurrent use. The clock is injectable for tests.

func NewDeduper

func NewDeduper(window time.Duration) *Deduper

NewDeduper returns a Deduper with the given window. A zero window disables dedup.

func (*Deduper) Seen

func (d *Deduper) Seen(key string) bool

Seen records the key and reports whether it was already seen within the window. The key must be non-empty. Expired entries are evicted on each call so the map stays bounded by the dedup window.

type Engine

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

Engine evaluates incidents against a policy, with dedup.

func NewEngine

func NewEngine(p config.IncidentTrigger) *Engine

NewEngine builds an Engine from the incident trigger policy.

func (*Engine) Decide

func (e *Engine) Decide(inc config.Incident) Decision

Decide returns whether the incident should start an investigation.

Jump to

Keyboard shortcuts

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