rules

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const StableSourceIDLabel = "nozin_source_id"

StableSourceIDLabel disambiguates rules that intentionally share a group and alert name inside one namespaced source collection. Unlike source positions and expressions, its value must remain stable across edits and reordering.

Variables

This section is empty.

Functions

func ValidateStableIdentities

func ValidateStableIdentities(sources []projectmodel.RuleSet) error

ValidateStableIdentities validates canonical explicit source IDs, rejects namespace-backed alerts that would resolve to the same SigNoz upsert key, and enforces ownership of generated target labels. The check is deliberately separate from Translate so callers can fail before metadata requests, artifact publication, or target mutation.

Types

type AlertNameInventory

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

AlertNameInventory carries collection-wide duplicate counts so target alert names remain unique and stable when one migration run spans multiple files. Its maps are immutable after construction.

func NewAlertNameInventory

func NewAlertNameInventory(sources []projectmodel.RuleSet) AlertNameInventory

NewAlertNameInventory counts alert names and normalized severities across a complete source collection before any artifact or target mutation.

type GroupMigration

type GroupMigration struct {
	Source projectmodel.RuleGroup `json:"source"`
	Rules  []RuleMigration        `json:"rules"`
}

GroupMigration preserves source grouping for the evidence report.

type Migration

type Migration struct {
	Source projectmodel.RuleSet `json:"source"`
	Groups []GroupMigration     `json:"groups"`
}

Migration contains source rules and their target translations.

func Translate

func Translate(source projectmodel.RuleSet, analyzer *transpile.Analyzer) Migration

Translate converts every source rule without dropping recording rules.

func TranslateWithAlertNameInventory

func TranslateWithAlertNameInventory(
	source projectmodel.RuleSet,
	analyzer *transpile.Analyzer,
	inventory AlertNameInventory,
) Migration

TranslateWithAlertNameInventory translates one source using counts from the entire input collection. Callers migrating several files must share one inventory across every call.

type RuleMigration

type RuleMigration struct {
	Source             projectmodel.Rule     `json:"source"`
	Decision           projectmodel.Decision `json:"decision"`
	Payload            *signoz.AlertRuleV2   `json:"payload,omitempty"`
	Query              string                `json:"query,omitempty"`
	Operator           string                `json:"operator,omitempty"`
	Target             float64               `json:"target,omitempty"`
	ExtractedThreshold bool                  `json:"extractedThreshold"`
}

RuleMigration is one source rule, decision, and optional SigNoz payload.

Jump to

Keyboard shortcuts

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