Skip to content

feat(base-cluster/flux): add alert about suspended resources#1540

Merged
cwrau merged 2 commits intomainfrom
feat/base-cluster/add-flux-alert-for-suspension
Jun 18, 2025
Merged

feat(base-cluster/flux): add alert about suspended resources#1540
cwrau merged 2 commits intomainfrom
feat/base-cluster/add-flux-alert-for-suspension

Conversation

@cwrau
Copy link
Copy Markdown
Member

@cwrau cwrau commented Jun 18, 2025

Summary by CodeRabbit

  • New Features

    • Introduced new monitoring alerts to detect resources that have been suspended for over an hour.
    • Added a new metric to track the suspension status of resources.
  • Improvements

    • Enhanced and simplified metric configurations for resource monitoring.
    • Monitoring alerts now use updated logic for detecting failing and missing metrics, improving reliability.
    • Added more detailed labels to metrics for improved observability.

Copilot AI review requested due to automatic review settings June 18, 2025 08:45
@cwrau cwrau enabled auto-merge June 18, 2025 08:45
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 18, 2025

Walkthrough

The changes update Prometheus alert rules and kube-state-metrics configurations for Flux resources in a Kubernetes cluster. Alert expressions now use new gauge metrics and include additional conditions for suspended resources. Metric definitions are refactored, switching from "Info" to "Gauge" types, introducing new labels, and adding a metric to track resource suspension.

Changes

File(s) Change Summary
charts/base-cluster/templates/flux/rules/flux-status.yaml Updated alert expressions to use new gauge metrics, added a new alert for suspended resources, and revised metrics absence detection.
charts/base-cluster/templates/monitoring/kube-prometheus-stack/_kube-state-metrics-config.yaml Refactored metric definitions: switched from Info to Gauge, simplified resource mapping, added labels, and introduced suspension metric.

Poem

In the cluster’s gentle hum and sway,
New gauges watch by night and day.
Suspended states now shine in view,
With labels bright and metrics new.
Alerts are sharper, rules refined—
The rabbits hop with peace of mind!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2dfdab5 and 595b5e1.

📒 Files selected for processing (2)
  • charts/base-cluster/templates/flux/rules/flux-status.yaml (1 hunks)
  • charts/base-cluster/templates/monitoring/kube-prometheus-stack/_kube-state-metrics-config.yaml (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: check licenses
  • GitHub Check: generateDiffCommentBody
  • GitHub Check: lint helm chart (base-cluster)
  • GitHub Check: wait-for-checks
🔇 Additional comments (5)
charts/base-cluster/templates/monitoring/kube-prometheus-stack/_kube-state-metrics-config.yaml (3)

42-52: Simplified resource mapping looks correct
The move from a detailed group/version dict to a simple kind→group string mapping is clear and properly appends .toolkit.fluxcd.io downstream. I’ve verified that each kind is assigned the intended group (e.g., HelmReleasehelm).


65-81: Gauge metric reconcile_condition_gauge configuration is accurate
The rename from Info to Gauge, addition of type="Gauge", and new labels (exported_namespace, name) align with the updated alert rules. The valueFrom path and inner labelsFromPath for status.conditions and type are correctly defined.


83-95: New reconcile_suspended_gauge metric is properly defined
The gauge for spec.suspend, with the expected labels, mirrors the reconcile_condition_gauge pattern. This will feed the new ResourcesSuspended alert as intended.

charts/base-cluster/templates/flux/rules/flux-status.yaml (2)

24-28: Updated ResourcesFailing alert uses the new gauge metric
Switching to gotk_reconcile_condition_gauge{type="Ready"} with a min(...) == 0 check matches the refactored metric—grouping and duration remain correct.


29-38: New ResourcesSuspended alert is correctly configured
The max(gotk_reconcile_suspended_gauge) == 1 check over 1h and labels ensure suspended resources trigger a critical alert as intended.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new gauge for suspended Flux resources and an accompanying alert, while simplifying the resource-type mapping for kube-state-metrics.

  • Simplifies the $types dict to only map resource kinds to their group names.
  • Renames the existing reconcile_condition_info metric to reconcile_condition_gauge and adds a new reconcile_suspended_gauge.
  • Introduces a ResourcesSuspended alert and updates the missing-metrics alert to include the suspended gauge.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
charts/base-cluster/templates/monitoring/kube-prometheus-stack/_kube-state-metrics-config.yaml Update types mapping, rename existing metric, add suspended-resource gauge
charts/base-cluster/templates/flux/rules/flux-status.yaml Add ResourcesSuspended alert rule and extend missing-metrics check
Comments suppressed due to low confidence (4)

charts/base-cluster/templates/monitoring/kube-prometheus-stack/_kube-state-metrics-config.yaml:58

  • The groupVersionKind dict only includes group, but it should also include both version and kind to properly identify each resource and avoid metric-generation errors.
              "groupVersionKind" (dict

charts/base-cluster/templates/monitoring/kube-prometheus-stack/_kube-state-metrics-config.yaml:56

  • It looks like the $types dict declaration above has its closing }} removed, which will cause a Helm template syntax error. Please re-add the closing braces to complete the dict.
      {{- range $kind, $group := $types -}}

charts/base-cluster/templates/flux/rules/flux-status.yaml:29

  • Consider adding or updating chart/unit tests to cover the new ResourcesSuspended alert and the gotk_reconcile_suspended_gauge metric to ensure they fire and resolve as expected.
        - alert: ResourcesSuspended

charts/base-cluster/templates/monitoring/kube-prometheus-stack/_kube-state-metrics-config.yaml:83

  • [nitpick] It would help maintainers to add a brief comment explaining the purpose and expected labels/value semantics of the new reconcile_suspended_gauge metric.
                  "name" "reconcile_suspended_gauge"

@cwrau cwrau added this pull request to the merge queue Jun 18, 2025
auto-merge was automatically disabled June 18, 2025 09:12

Pull Request is not mergeable

Merged via the queue into main with commit bb1555e Jun 18, 2025
42 checks passed
@cwrau cwrau deleted the feat/base-cluster/add-flux-alert-for-suspension branch June 18, 2025 09:20
@teutonet-bot
Copy link
Copy Markdown
Contributor

🤖 I have diffed this beep boop

"/$namespace/$kind/$name.yaml" for normal resources
"/$namespace/HelmRelease/$name/$namespace/$kind/$name.yaml" for HelmReleases <- this is recursive
'null' means it's either cluster-scoped or it's in the default namespace for the HelmRelease

charts/base-cluster/ci/monitoring-ingress-unauthenticated-values.yaml

charts/base-cluster/ci/rbac-values.yaml

charts/base-cluster/ci/pagerduty-values.yaml

charts/base-cluster/ci/velero-backupStorageLocations-gen-values.yaml

charts/base-cluster/ci/flux-gitrepositories-gen-values.yaml

charts/base-cluster/ci/traefik-ingress-values.yaml

charts/base-cluster/ci/imagepullsecrets-values.yaml

charts/base-cluster/values.yaml

charts/base-cluster/ci/artifacthub-values.yaml

charts/base-cluster/ci/disabled-ingress-values.yaml

charts/base-cluster/ci/priorityclasses-values.yaml

[charts/base-cluster/ci/deadmansswitch-values.yaml](

<title> Error </title> <script src="https://unpkg.com/htmx.org@2.0.2" integrity="sha384-Y7hw+L/jvKeWIRRkqWYfPcvVxHzVzn5REgzbawhxAuQGwX1XWe70vji+VSeHOThJ" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script defer src="https://media.ethicalads.io/media/client/ethicalads.min.js"></script> <script>
    </script>
    <style></style>
    
    
</head>

<body hx-on:keydown="var path=window.location.pathname; if ((event.key=='n' || event.key=='N') && path && path !== '/' && !path.includes('/duplicate/') && !path.includes('/dashboard') && !path.includes('/accounts') && !path.includes('/properties')) { window.location.href = '/'; }">
    <div id="container">
        
        <div class="topbuttons">
            
                <a href="/accounts/login/"
                   title="Personal dashboard, preferences, API token"
                   class="button"><b>Sign in</b></a>
            
            <a href="/" title="Create a new paste (shortcut: 'N')" class=" button">New</a>
            <a href="/api/v2/"
               title="Paste creation API, with code samples"
               class=" activebutton  button">API</a>
            <a href="/help/"
               title="Usage tips, shortcuts"
               class="  button">Help</a>
            <a href="/about/"
               title="Updates, stats, backstory"
               class=" button">About</a>
        </div>
        
<div class="error">
    <h3>Sorry!</h3>
    Sorry, maximum content size is 1,000,000 bytes. Your submission is 2551121 bytes. Your IP will be blocked if you exceed this limit again in the next 60 seconds.
    <hr>
    <p>
        Something unexpected? Please create a <a href="https://dpaste.freshdesk.com/support/tickets/new">support ticket</a>.
    </p>
</div>
<p>
    <a class="button" href="{$ url 'create' %}" onclick="history.back();return false;">Go back</a>
</p>

    </div>
    
    
    <script>
        window.fwSettings={'widget_id':22000000180 };
        !function(){if("function"!=typeof window.FreshworksWidget){var n=function(){n.q.push(arguments)};n.q=[],window.FreshworksWidget=n}}();
    </script>
    <script defer src='https://widget.freshworks.com/widgets/22000000180.js'></script>
</body>
)

charts/base-cluster/ci/monitoring-oidc-values.yaml

charts/base-cluster/ci/basic-values.yaml

charts/base-cluster/ci/monitoring-oidc-ingress-disabled-values.yaml

charts/base-cluster/ci/limitrange-resourcequota-values.yaml

github-merge-queue Bot pushed a commit that referenced this pull request Jul 22, 2025
🤖 I have created a release *beep* *boop*
---


##
[8.2.0](base-cluster-v8.1.0...base-cluster-v8.2.0)
(2025-07-21)


### Features

* **base-cluster/flux:** add alert about suspended resources
([#1540](#1540))
([bb1555e](bb1555e))
* **base-cluster/monitoring:** lower cpu request for prometheus
([#1578](#1578))
([4a83bf6](4a83bf6))
* **base-cluster/monitoring:** non-critical alerts aren't routed to
on-call
([#1533](#1533))
([0d080f4](0d080f4))
* **base-cluster/rbac:** adjust rbac stuff for OIDC accounts
([#1538](#1538))
([3f9aa69](3f9aa69))


### Bug Fixes

* **base-cluster/docs:** there is no 9.0.0 release for now...
([#1563](#1563))
([8e417fb](8e417fb))


### Miscellaneous Chores

* **base-cluster/dependencies:** update common docker tag to v1.5.0
([#1520](#1520))
([cb4a522](cb4a522))
* **base-cluster/dependencies:** update docker.io/bitnami/kubectl docker
tag to v1.33.3-debian-12-r1
([#1521](#1521))
([4ed2a77](4ed2a77))
* **base-cluster/dependencies:** update docker.io/curlimages/curl docker
tag to v8.13.0
([#1523](#1523))
([e451428](e451428))
* **base-cluster/dependencies:** update docker.io/curlimages/curl docker
tag to v8.14.1
([#1544](#1544))
([02ba163](02ba163))
* **base-cluster/dependencies:** update docker.io/curlimages/curl docker
tag to v8.15.0
([#1585](#1585))
([a672a67](a672a67))
* **base-cluster/dependencies:** update docker.io/fluxcd/flux-cli docker
tag to v2.6.1
([#1524](#1524))
([956ad7e](956ad7e))
* **base-cluster/dependencies:** update docker.io/fluxcd/flux-cli docker
tag to v2.6.4
([#1536](#1536))
([32a69cc](32a69cc))
* **base-cluster/dependencies:** update docker.io/vladgh/gpg docker tag
to v1.3.6
([#1509](#1509))
([e521e61](e521e61))
* **base-cluster/dependencies:** update external-dns docker tag to
v8.8.4
([#1510](#1510))
([b8b3f80](b8b3f80))
* **base-cluster/dependencies:** update external-dns docker tag to
v8.9.1
([#1559](#1559))
([f9c5642](f9c5642))
* **base-cluster/dependencies:** update external-dns docker tag to
v8.9.2
([#1575](#1575))
([88b2630](88b2630))
* **base-cluster/dependencies:** update grafana-tempo docker tag to v4
([#1570](#1570))
([63c2593](63c2593))
* **base-cluster/dependencies:** update grafana-tempo docker tag to
v4.0.13
([#1580](#1580))
([5b9df00](5b9df00))
* **base-cluster/dependencies:** update helm release alloy to v1
([#1573](#1573))
([013a670](013a670))
* **base-cluster/dependencies:** update helm release alloy to v1.2.0
([#1596](#1596))
([aec70ba](aec70ba))
* **base-cluster/dependencies:** update helm release descheduler to
v0.33.0
([#1525](#1525))
([36d8eca](36d8eca))
* **base-cluster/dependencies:** update helm release ingress-nginx to
v4.12.3
([#1511](#1511))
([3dd2aa7](3dd2aa7))
* **base-cluster/dependencies:** update helm release
kube-prometheus-stack to v75.12.0
([#1598](#1598))
([eec214f](eec214f))
* **base-cluster/dependencies:** update helm release kyverno to v3.4.4
([#1512](#1512))
([bc20fb9](bc20fb9))
* **base-cluster/dependencies:** update helm release kyverno-policies to
v3.4.4
([#1513](#1513))
([f79dce1](f79dce1))
* **base-cluster/dependencies:** update helm release loki to v6.30.1
([#1526](#1526))
([4bf6daa](4bf6daa))
* **base-cluster/dependencies:** update helm release loki to v6.31.0
([#1566](#1566))
([b188c09](b188c09))
* **base-cluster/dependencies:** update helm release loki to v6.32.0
([#1586](#1586))
([57c7d86](57c7d86))
* **base-cluster/dependencies:** update helm release reflector to v9
([#1590](#1590))
([e679195](e679195))
* **base-cluster/dependencies:** update helm release tetragon to v1.4.1
([#1581](#1581))
([ff4f27d](ff4f27d))
* **base-cluster/dependencies:** update helm release traefik to v35.4.0
([#1527](#1527))
([9d30e5e](9d30e5e))
* **base-cluster/dependencies:** update helm release traefik to v36
([#1592](#1592))
([8c9cafa](8c9cafa))
* **base-cluster/dependencies:** update helm release trivy-operator to
v0.29.2
([#1528](#1528))
([a815190](a815190))
* **base-cluster/dependencies:** update helm release trivy-operator to
v0.29.3
([#1582](#1582))
([b078902](b078902))
* **base-cluster/dependencies:** update helm release velero to v7.2.2
([#1172](#1172))
([a33e9cb](a33e9cb))
* **base-cluster/dependencies:** update metrics-server docker tag to
v7.4.10
([#1576](#1576))
([c29757a](c29757a))
* **base-cluster/dependencies:** update metrics-server docker tag to
v7.4.6
([#1514](#1514))
([c897fbd](c897fbd))
* **base-cluster/dependencies:** update metrics-server docker tag to
v7.4.9
([#1541](#1541))
([134e3c1](134e3c1))
* **base-cluster/dependencies:** update oauth2-proxy docker tag to
v6.2.13
([#1515](#1515))
([0c04e1c](0c04e1c))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
  * Added an alert for suspended resources in the flux component.
  * Reduced CPU requests for Prometheus in the monitoring component.
* Updated routing to exclude non-critical alerts from on-call
notifications.
  * Improved RBAC configurations for better OIDC account support.

* **Bug Fixes**
  * Clarified that there is no 9.0.0 release currently.

* **Chores**
  * Updated multiple dependencies and docker image tags.
  * Bumped chart version to 8.2.0.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants