Skip to content

Add the observability render pipeline with alert rule templates, promtool tests and CI #184

Description

@sourcehawk

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.

Metadata

Metadata

Assignees

Labels

featureUser-observable capability or surface

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions