controllers

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabelCCloudSupportGroup = "ccloud/support-group"
	LabelCCloudService      = "ccloud/service"

	LabelSupportGroup = "support_group"
	LabelTier         = "tier"
	LabelService      = "service"
)

These constants are exported for reusability across packages.

View Source
const (
	DefaultAbsencePromRuleNameTemplate = `` /* 149-byte string literal not displayed */
)

Variables

View Source
var IsTest bool

IsTest is set by the test suite during testing.

Functions

func AbsenceRuleGroupName added in v0.9.6

func AbsenceRuleGroupName(promRule, ruleGroup string) string

AbsenceRuleGroupName returns the name of the RuleGroup that holds absence alert rules for a specific RuleGroup in a specific PrometheusRule.

func ParseRuleGroups

func ParseRuleGroups(logger logr.Logger, in []monitoringv1.RuleGroup, promRuleName string, keepLabel KeepLabel) ([]monitoringv1.RuleGroup, error)

ParseRuleGroups takes a slice of RuleGroup that has alert rules and returns a new slice of RuleGroup that has the corresponding absence alert rules.

The labels specified in the keepLabel map will be carried over to the corresponding absence alerts unless templating (i.e. $labels) was used for these labels.

The rule group names for the absence alerts have the format: promRuleName/originalGroupName.

func RegisterMetrics

func RegisterMetrics() *prometheus.Registry

RegisterMetrics registers all the metrics. If IsTest is true then it will also return a *prometheus.Registry than can be used in the test suite otherwise nil is returned.

Types

type AbsencePromRuleNameGenerator added in v0.9.6

type AbsencePromRuleNameGenerator func(*monitoringv1.PrometheusRule) (string, error)

AbsencePromRuleNameGenerator is a function type that takes a PrometheusRule and generates a name for its corresponding PrometheusRule that holds the generated absence alert rules.

func CreateAbsencePromRuleNameGenerator added in v0.9.6

func CreateAbsencePromRuleNameGenerator(tmplStr string) (AbsencePromRuleNameGenerator, error)

CreateAbsencePromRuleNameGenerator creates an absencePromRuleNameGenerator function based on a template string.

type KeepLabel

type KeepLabel map[string]bool

KeepLabel specifies which labels to keep on an absence alert rule.

type PrometheusRuleReconciler

type PrometheusRuleReconciler struct {
	client.Client
	Scheme *runtime.Scheme
	Log    logr.Logger

	PrometheusRuleName AbsencePromRuleNameGenerator
	// KeepLabel is a map of labels that will be retained from the original alert rule and
	// passed on to its corresponding absence alert rule.
	KeepLabel KeepLabel
}

PrometheusRuleReconciler reconciles a PrometheusRule object.

func (*PrometheusRuleReconciler) Reconcile

Reconcile is part of the main Kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.11.0/pkg/reconcile

func (*PrometheusRuleReconciler) SetupWithManager

func (r *PrometheusRuleReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

Jump to

Keyboard shortcuts

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