feat(monitoring): Mimir rules ConfigMap (Prometheus-free rule delivery) - #468
feat(monitoring): Mimir rules ConfigMap (Prometheus-free rule delivery)#468christopherfickess wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds ConfigMap-based alert-rule delivery for Grafana Alloy and Mimir deployments without a Prometheus server.
Changes:
- Adds the
spec.monitoring.mimirRulesAPI. - Generates and reconciles Mimir rule ConfigMaps.
- Adds generation tests and deployment documentation.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
apis/mattermost/v1beta1/mattermost_types.go |
Defines the Mimir rules API. |
apis/mattermost/v1beta1/zz_generated.deepcopy.go |
Adds generated deep-copy support. |
config/crd/bases/installation.mattermost.com_mattermosts.yaml |
Exposes the API through the CRD. |
controllers/mattermost/mattermost/controller.go |
Watches owned ConfigMaps. |
controllers/mattermost/mattermost/monitoring.go |
Reconciles and deletes rule ConfigMaps. |
docs/examples/mattermost_monitoring_mimir.yaml |
Documents Alloy and Mimir configuration. |
pkg/mattermost/monitoring.go |
Generates ConfigMaps containing alert rules. |
pkg/mattermost/monitoring_test.go |
Tests rule ConfigMap generation. |
pkg/resources/create_resources.go |
Adds ConfigMap creation support. |
Files not reviewed (1)
- apis/mattermost/v1beta1/zz_generated.deepcopy.go: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
0b3a158 to
e93eefd
Compare
c73548c to
9763ed7
Compare
5f9b006 to
b74f328
Compare
|
Thanks for the review — here's the resolution. Fixed:
discoveryLabel vs marker-label collision: the marker label key ( This PR is stacked on #466 (rebased so the diff is only the Mimir delta). Shared CI fixes (openapi, gofmt, CEL removal, server-side apply) come from the base. |
8f1c7e1 to
5aca2d6
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- apis/mattermost/v1beta1/zz_generated.deepcopy.go: Generated file
Suppressed comments (1)
controllers/mattermost/mattermost/monitoring_reconcile_test.go:40
- This reconcile test never enables
MimirRulesor asserts that its ConfigMap is created, remains stable, and is removed on disable. The generator test does not exercise the newly added controller/create/update/label-selected cleanup paths, so the PR's central reconciliation behavior is currently uncovered. Extend this test with the Mimir flag and ConfigMap create/delete assertions.
Monitoring: &mmv1beta.Monitoring{
ServiceMonitor: &mmv1beta.ServiceMonitor{Enabled: true},
PrometheusRule: &mmv1beta.PrometheusRule{Enabled: true},
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- apis/mattermost/v1beta1/zz_generated.deepcopy.go: Generated file
Suppressed comments (1)
controllers/mattermost/mattermost/monitoring_reconcile_test.go:41
- This reconcile test never enables
MimirRules, so the new controller create/idempotency/cleanup path is not exercised; only the pre-existing ServiceMonitor and PrometheusRule paths are covered. Add the Mimir setting plus assertions thatmm-mimir-rulesis created, remains stable on the second reconcile, and is deleted after disabling it.
Monitoring: &mmv1beta.Monitoring{
ServiceMonitor: &mmv1beta.ServiceMonitor{Enabled: true},
PrometheusRule: &mmv1beta.PrometheusRule{Enabled: true},
},
2fc1523 to
183d869
Compare
183d869 to
6a9f3b5
Compare
Prometheus-free rule delivery for a Grafana Alloy + Mimir stack. Adds spec.monitoring.mimirRules: the same per-instance, pod-scoped alert rules as prometheusRule, delivered as a ConfigMap for a Mimir ruler-sync instead of a PrometheusRule CRD. Create/update refuses to overwrite, and cleanup deletes only, ConfigMaps this CR controls. ServiceMonitor + metrics Service unchanged. Re-seated onto the updated base so the diff is only the Mimir delta. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mirror the CodeRabbit hardening applied to the other generators: - GenerateMimirRulesConfigMapV1Beta returns nil when spec.monitoring is unset, so direct callers don't panic (the reconcile path already guards this via mimirRulesEnabled). - Reject a mimirRules.discoveryLabel that collides with the reserved marker key, which would otherwise be silently overwritten during label assembly and break ruler-sync discovery. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Regenerated via `make yaml` so the bundle carries the full spec.monitoring schema (including mimirRules) and the servicemonitors/prometheusrules/ events RBAC. The committed bundle was stale (Copilot review). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
af0d042 to
0af56f5
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- apis/mattermost/v1beta1/zz_generated.deepcopy.go: Generated file
Suppressed comments (1)
controllers/mattermost/mattermost/monitoring.go:46
- The existing monitoring reconcile test covers create, idempotent reconcile, and cleanup for every other monitoring resource, but it never enables or asserts the new Mimir ConfigMap path. Add the Mimir option and ConfigMap assertions so the ownership guard and label-based cleanup-on-disable are exercised; otherwise regressions in the lifecycle promised by this feature are untested.
if err := r.checkMattermostPrometheusRule(mattermost, reqLogger); err != nil {
return err
}
return r.checkMattermostMimirRules(mattermost, reqLogger)
The Mimir feature commit predated the clusterIPs-preservation fix, so its copy of reconcileService won during rebase and dropped the call. Restore resources.CopyServiceEmptyAutoAssignedFields(desired, current) before Update, matching the base branch -- without it, updates to the headless metrics Service try to clear the immutable clusterIPs (["None"]) and fail. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Draft POC — the Prometheus-free rule-delivery option, for the "Grafana Alloy + Mimir instead of Prometheus" direction.
Background: on a Grafana Alloy + Mimir stack, almost everything the operator emits is already backend-neutral — the ServiceMonitor and the dedicated metrics Service are consumed by Grafana Alloy (
prometheus.operator.servicemonitors), which remote-writes to Mimir, and the dashboards are Grafana-native. The one Prometheus-specific piece is alert-rule delivery: Alloy/Mimir don't consume thePrometheusRuleCRD. This PR adds that seam.Adds
spec.monitoring.mimirRules:prometheusRule, but as a plain ConfigMap in Prometheus rules format (groups:) for a Mimir ruler-sync (mimirtool or a sidecar) to load — instead of aPrometheusRuleCRD.mimir_rules: "1") for the ruler-sync, plus an optionaltenantannotation for multi-tenant Mimir.Owns(ConfigMap), consistent with the rest of the monitoring reconcile.No changes to ServiceMonitor / metrics Service / client+calls metrics — this is purely additive.
Cluster prerequisites (documented in
docs/examples/mattermost_monitoring_mimir.yaml): install the prometheus-operator CRDs only (no Prometheus server) so Alloy can discover the ServiceMonitor; run Alloy scraping kube-state-metrics + cAdvisor (the CPU/mem/crash-loop alerts depend on those series —metrics-serverdoes not provide them); and run a Mimir ruler-sync that loadsmimir_rules-labelled ConfigMaps.Ticket Link
Internal SRE monitoring POC — no public ticket. Alternative rule delivery for #466; companion to #467 (dashboards).
Release Note
🤖 Generated with Claude Code