coalesce

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 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 Constituents added in v0.9.0

func Constituents(batch []investigate.Request) []string

Constituents returns the DISTINCT constituent identities of a coalesced batch OTHER than the representative's (batch[0]) own, for surfacing in the seed as the storm's blast radius. Each entry prefers the workload ref ("ns/name" or "ns"), falling back to the alert title when the alert carries no workload. Order is stable (first-seen) and the list is capped at maxConstituents. Returns nil for a singleton batch (nothing beyond the representative to surface).

func Summarize

func Summarize(reqs []investigate.Request) 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([]investigate.Request)) *Coalescer

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

func (*Coalescer) Add

func (c *Coalescer) Add(r investigate.Request)

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

func (*Coalescer) Enqueue added in v0.2.0

func (c *Coalescer) Enqueue(r investigate.Request)

Enqueue satisfies investigate.Enqueuer by folding the request through the coalescer, so a source pipeline can route admitted Requests through coalescing.

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