processor

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProcessor

func NewProcessor(healthMapMetrics, componentsMetrics prom.MetricSet, interval time.Duration, promURL string) (*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 map[string]string // Identifying labels of the source
	GroupId   string            // Group ID of the component
	Health    HealthValue       // Health value of the component
}

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

func MapAlerts

func MapAlerts(alerts []prom.Alert) []ComponentHealthMap

MapAlerts maps prometheus alerts to component health maps.

func (ComponentHealthMap) Labels

func (c ComponentHealthMap) Labels() map[string]string

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 []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 []prom.Alert, timestamp time.Time) []prom.Alert

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_"
)

type Interval

type Interval struct {
	Metric prom.PromMetric
	Start  model.Time
	End    model.Time
}

func MetricsIntervals

func MetricsIntervals(rangeVector prom.RangeVector) []Interval

func (Interval) String

func (i Interval) String() string

type LabelsMatcher

type LabelsMatcher interface {
	Matches(labels map[string]string) (match bool, keys []string)
	Equals(other LabelsMatcher) bool
}

type SrcType

type SrcType string

SrcType represents the type of the source.

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

type ValueMatcher

type ValueMatcher interface {
	Matches(value string) bool
	Equals(other ValueMatcher) bool
}

ValueMatcher represents a matcher for a specific value.

Multiple implementations are provided for different types of matchers.

Jump to

Keyboard shortcuts

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