Add the observability render pipeline with alert rule templates, promtool tests and CI
Problem
Operators built on the framework have no alert rules for the metrics the framework and controller-runtime emit, and no way to render templated rules for their metric namespace from this repository. The condition alerts in go-crd-condition-metrics exist, but they are not shipped here and do not cover the framework's apply counters or controller-runtime.
Approach
- Create
observability/ with alerts/crd_conditions.tpl.yaml (the three upstream condition alerts carried over, rendered per metric namespace), plus two shared cluster-wide rule files installed once per cluster: alerts/managed_resources.yaml (ManagedResourceNotConverging, ManagedResourceApplyFailing) and alerts/controller_runtime.yaml (ControllerReconcileErrors, ControllerReconcilePanics, ControllerWorkqueueBacklog, ControllerReconcileLatencyHigh, OperatorLeaderMissing), each with a promtool unit test file under alerts/tests/.
- Add an
##@ Observability section to the root Makefile: alerts, dashboards, test-alerts, with METRIC_NAMESPACE, NAMESPACE_LABEL (default exported_namespace), ALERT_FORMAT (prometheusrule default, rules), and optional PROMETHEUSRULE_NAMESPACE / PROMETHEUSRULE_LABELS metadata for ruleSelector-based installs. Placeholders are {{operator_namespace}} and {{namespace_label}}; output goes to the gitignored observability/generated/. Templates render as <metric-namespace>-<name>; shared files wrap as ocf-<name>.
- The not-converging and apply-failing rules use ratios of the resource's own applies with an absolute floor, keyed on
(namespace, controller, owner_kind, component, resource, kind), so they are safe at scale; controller-runtime thresholds sit on real histogram bucket bounds; every rule ships as severity: warning with no routing labels.
- Add a CI job that installs a pinned promtool and runs
make test-alerts.
observability/README.md with the render commands.
Verification
make test-alerts passes: rules lint clean with both namespace label variants and every unit test passes, including the negative cases (legitimate churn at scale does not fire ManagedResourceNotConverging; sporadic conflicts do not fire ManagedResourceApplyFailing; a second healthy install of the same operator does not mask an erroring one).
make alerts METRIC_NAMESPACE=demo writes demo-crd-conditions, ocf-managed-resources and ocf-controller-runtime PrometheusRule objects; ALERT_FORMAT=rules writes plain rule files that promtool check rules accepts.
make alerts without METRIC_NAMESPACE fails with a usage hint.
- The CI job runs on pull requests and passes.
Context
Sub-issue of #183.
Add the observability render pipeline with alert rule templates, promtool tests and CI
Problem
Operators built on the framework have no alert rules for the metrics the framework and controller-runtime emit, and no way to render templated rules for their metric namespace from this repository. The condition alerts in
go-crd-condition-metricsexist, but they are not shipped here and do not cover the framework's apply counters or controller-runtime.Approach
observability/withalerts/crd_conditions.tpl.yaml(the three upstream condition alerts carried over, rendered per metric namespace), plus two shared cluster-wide rule files installed once per cluster:alerts/managed_resources.yaml(ManagedResourceNotConverging,ManagedResourceApplyFailing) andalerts/controller_runtime.yaml(ControllerReconcileErrors,ControllerReconcilePanics,ControllerWorkqueueBacklog,ControllerReconcileLatencyHigh,OperatorLeaderMissing), each with a promtool unit test file underalerts/tests/.##@ Observabilitysection to the rootMakefile:alerts,dashboards,test-alerts, withMETRIC_NAMESPACE,NAMESPACE_LABEL(defaultexported_namespace),ALERT_FORMAT(prometheusruledefault,rules), and optionalPROMETHEUSRULE_NAMESPACE/PROMETHEUSRULE_LABELSmetadata for ruleSelector-based installs. Placeholders are{{operator_namespace}}and{{namespace_label}}; output goes to the gitignoredobservability/generated/. Templates render as<metric-namespace>-<name>; shared files wrap asocf-<name>.(namespace, controller, owner_kind, component, resource, kind), so they are safe at scale; controller-runtime thresholds sit on real histogram bucket bounds; every rule ships asseverity: warningwith no routing labels.make test-alerts.observability/README.mdwith the render commands.Verification
make test-alertspasses: rules lint clean with both namespace label variants and every unit test passes, including the negative cases (legitimate churn at scale does not fireManagedResourceNotConverging; sporadic conflicts do not fireManagedResourceApplyFailing; a second healthy install of the same operator does not mask an erroring one).make alerts METRIC_NAMESPACE=demowritesdemo-crd-conditions,ocf-managed-resourcesandocf-controller-runtimePrometheusRuleobjects;ALERT_FORMAT=ruleswrites plain rule files thatpromtool check rulesaccepts.make alertswithoutMETRIC_NAMESPACEfails with a usage hint.Context
Sub-issue of #183.