coalesce

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: 8 Imported by: 0

Documentation

Overview

Package coalesce folds correlated Alertmanager incidents into a single investigation, suppressing the redundant per-alert investigations a storm would otherwise spawn. In-memory, mutex-guarded, clock injected for tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Summarize

func Summarize(incs []config.Incident) string

Summarize renders a one-line digest of a coalesced batch for the seed prompt.

Types

type Coalescer

type Coalescer struct {
	Metrics *telemetry.Metrics // optional; nil-safe OTel counters
	// contains filtered or unexported fields
}

Coalescer buffers correlated incidents and flushes one investigation per key.

func New

func New(cfg Config, out func([]config.Incident)) *Coalescer

New builds a Coalescer. out is called with each flushed batch.

func (*Coalescer) Add

func (c *Coalescer) Add(inc config.Incident)

Add ingests one incident: critical → flush now; within cooldown → suppress; else buffer (flushing when MaxBatch is reached).

func (*Coalescer) Run

func (c *Coalescer) Run(ctx context.Context, tick time.Duration)

Run sweeps on a ticker until ctx is cancelled. tick should be ~Debounce/2. A zero or negative tick is clamped to 1s to avoid a NewTicker panic.

type Config

type Config struct {
	Debounce          time.Duration
	MaxWait           time.Duration
	MaxBatch          int
	Cooldown          time.Duration
	CorrelationLabels []string
}

Config mirrors config.Coalesce with std durations. The enable gate lives in main.go — a constructed Coalescer is always active.

Jump to

Keyboard shortcuts

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