Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When adding alerting rule, provide a default namespace label #6527

Merged
merged 1 commit into from
Aug 3, 2022

Conversation

catherineluse
Copy link
Contributor

This PR addresses #6478 by modifying the default values for a new alerting rule so that it now creates a new label for namespace=default.

To test this PR,

  1. I installed monitoring.
  2. In the side nav of Cluster Explorer, I went to Monitoring > Advanced > PrometheusRules.
  3. Clicked Add Alert.
  4. Confirmed that in the form that appears, a default namespace=default label is there.

Screen Shot 2022-07-27 at 12 16 59 PM

5. Created the resource and confirmed the YAML was saved properly:
spec:
  groups:
    - name: rancher-qa
      rules:
        - alert: rancher-qa
          expr: vector(1)
          for: 0s
          labels:
            namespace: default
            severity: none
  1. Confirmed the saved value renders correctly in the detail view

Screen Shot 2022-07-27 at 12 18 31 PM

@catherineluse catherineluse marked this pull request as ready for review July 27, 2022 19:38
@catherineluse catherineluse requested a review from a user July 27, 2022 19:39
@nwmac nwmac added this to the v2.6.7 milestone Jul 27, 2022
@catherineluse catherineluse requested review from mantis-toboggan-md and removed request for a user July 28, 2022 16:08
if (!this.value.rules) {
this.value['rules'] = [defaultAlert];
} else if ( this.value.rules.length === 0) {
this.value['rules'] = [...this.value.rules, defaultAlert];
Copy link
Member

@mantis-toboggan-md mantis-toboggan-md Jul 28, 2022

Choose a reason for hiding this comment

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

Pr looks good, I'm just being nitpicky: is there a reason to include ...this.value.rules when the array is empty?

Copy link
Contributor Author

@catherineluse catherineluse Jul 29, 2022

Choose a reason for hiding this comment

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

No, this is a mistake. If the rule has already been created without any alerts, the default one shouldn't be added when it is edited. will fix

@catherineluse catherineluse merged commit 7f4ad74 into rancher:master Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants