processor

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package processor contains the core logic for processing alerts and updating the health map metrics.

Index

Constants

View Source
const (
	ClusterHealthComponentsMap = "cluster_health_components_map"

	AlertNameLabelKey = "alertname"
)

Variables

This section is empty.

Functions

func NewProcessor

func NewProcessor(cfg ProcessorConfig, healthMapMetrics, componentsMetrics prom.MetricSet, groupSeverityCountMetrics prom.MetricSet) (*processor, error)

Types

type Change

type Change struct {
	Timestamp model.Time
	Intervals []Interval
}

func (Change) String

func (c Change) String() string

type ChangeSet

type ChangeSet []Change

func MetricsChanges

func MetricsChanges(rangeVector prom.RangeVector) ChangeSet

MetricsChanges returns a list of changes in the alerts.

The changes are grouped by the timestamp of the change and sorted by the timestamp.

func (ChangeSet) String

func (ch ChangeSet) String() string

type ComponentHealthMap

type ComponentHealthMap struct {
	Layer     string         // Layer of the component
	Component string         // Component name
	SrcType   SrcType        // Type of the source (alert, cluster_operator_condition)
	SrcLabels model.LabelSet // Identifying labels of the source
	GroupId   string         // Group ID of the component
	Health    HealthValue    // Health value of the component
	Silenced  string         // Whether the alert is silenced or not
}

ComponentHealthMap represents mapping of a specific source to the component's health.

func MapAlerts

func MapAlerts(alerts []model.LabelSet) []ComponentHealthMap

MapAlerts maps prometheus alerts to component health maps.

func (ComponentHealthMap) Labels

func (c ComponentHealthMap) Labels() model.LabelSet

Labels to be exported for the mapping.

type ComponentRank

type ComponentRank struct {
	Layer     string
	Component string
	Rank      int
}

func BuildComponentRanks

func BuildComponentRanks() []ComponentRank

type GroupMatcher

type GroupMatcher struct {
	GroupID     string
	RootGroupID string
	Start       model.Time
	Modified    model.Time
	End         model.Time

	Distance float64
	Matchers []common.LabelsSubsetMatcher
}

func (GroupMatcher) String

func (g GroupMatcher) String() string

type GroupedInterval

type GroupedInterval struct {
	Interval
	GroupMatcher *GroupMatcher
}

func (GroupedInterval) String

func (gi GroupedInterval) String() string

type GroupsCollection

type GroupsCollection struct {
	Groups []*GroupMatcher
}

func (*GroupsCollection) AddGroup

func (gc *GroupsCollection) AddGroup(g *GroupMatcher)

func (*GroupsCollection) ProcessAlertsBatch

func (gc *GroupsCollection) ProcessAlertsBatch(alerts []model.LabelSet, timestamp time.Time) []model.LabelSet

func (*GroupsCollection) ProcessIntervalsBatch

func (gc *GroupsCollection) ProcessIntervalsBatch(intervals []Interval) []GroupedInterval

func (*GroupsCollection) PruneGroups

func (gc *GroupsCollection) PruneGroups(t time.Time)

PruneGroups removes groups that can't be matched anymore.

It calculates the threshold based on the provided time and removes groups.

func (*GroupsCollection) UpdateGroupUUIDs

func (gc *GroupsCollection) UpdateGroupUUIDs(healthMapRV prom.RangeVector)

type HealthValue

type HealthValue int

HealthValue represents the health value of the component.

const (
	Healthy  HealthValue = 0
	Warning  HealthValue = 1
	Critical HealthValue = 2

	SrcLabelPrefix = "src_"
)

func ParseHealthValue added in v1.2.0

func ParseHealthValue(s string) HealthValue

func (HealthValue) String added in v1.2.0

func (h HealthValue) String() string

type Interval

type Interval struct {
	Metric model.LabelSet
	Start  model.Time
	End    model.Time
}

func MetricsIntervals

func MetricsIntervals(rangeVector prom.RangeVector) []Interval

func (Interval) String

func (i Interval) String() string

type ProcessorConfig added in v1.2.0

type ProcessorConfig struct {
	Interval        time.Duration
	PromURL         string
	AlertManagerURL string
}

type SrcType

type SrcType string

SrcType represents the type of the source.

const (
	Alert                    SrcType = "alert"
	ClusterOperatorCondition SrcType = "cluster_operator_condition"
)

Jump to

Keyboard shortcuts

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