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

Rule patching can use index to distinguish alert / record rules under the same name #1331

Closed
wants to merge 1 commit into from

Conversation

raptorsun
Copy link
Contributor

  • I added CHANGELOG entry for this change.
  • No user facing changes, so no entry in CHANGELOG was needed.

The function patchOrExcludeRule uses an additional field "index" to distinguish different rules under the same name (alert/record field is considered as its name). Rules under the same group are ordered by alphabetic order in output.

For example, the following patch will add the field "patch:'A1' to the second rule of "alert:'A'".

local patchedRules = [
  {
    name: 'alertmanager.rules',
    rules: [
      {
        alert: 'A',
        index: 1,
        patch: 'A1',
        labels: {
          severity: 'warning',
        },
      },
      {
        alert: 'B',
        patch: 'B0',
        labels: {
          severity: 'warning',
        },
      },
      {
        alert: 'C',
        patch: 'C0',
        labels: {
          severity: 'warning',
        },
      },
      {
        alert: 'D',
        patch: 'D0',
        labels: {
          severity: 'warning',
        },
      },
    ],
  },
];

local rulesToPatch = [
  {
    name: 'alertmanager.rules',
    rules: [
      {
        alert: 'A',
        field: 'A0 rule',
        labels: {
          severity: 'warning',
        },
      },
      {
        alert: 'A',
        field: 'A1 rule',
        labels: {
          severity: 'warning',
        },
      },
      {
        alert: 'B',
        field: 'B0 rule',
        labels: {
          severity: 'warning',
        },
      },
    ],
  },
];

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 20, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: raptorsun

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 20, 2021
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 21, 2021
@raptorsun
Copy link
Contributor Author

Another PR with this rule patching function has been created in prometheus-operator/kube-prometheus repository, too.

@openshift-ci openshift-ci bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 2, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 6, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 9, 2021

@raptorsun: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 9, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 17, 2021

@raptorsun: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-aws-single-node 6a4cf14 link /test e2e-aws-single-node
ci/prow/e2e-agnostic 6a4cf14 link /test e2e-agnostic
ci/prow/e2e-agnostic-upgrade 6a4cf14 link /test e2e-agnostic-upgrade
ci/prow/e2e-agnostic-operator 6a4cf14 link /test e2e-agnostic-operator
ci/prow/go-fmt 6a4cf14 link /test go-fmt

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@dgrisonnet
Copy link
Member

Since we don't need this now in CMO, it would be better to add this functionality in kube-prometheus and bring it to CMO by reusing the upstream jsonnet script, wdyt?

@raptorsun
Copy link
Contributor Author

Since we don't need this now in CMO, it would be better to add this functionality in kube-prometheus and bring it to CMO by reusing the upstream jsonnet script, wdyt?

Totally agree, I will close this PR, and use this PR in kube-prometheus to add this functionality instead.

@raptorsun raptorsun closed this Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants