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

Plan including cortex_rule with multi-line expressions always show changes #15

Open
janakerman-form3 opened this issue Dec 6, 2021 · 1 comment

Comments

@janakerman-form3
Copy link
Contributor

janakerman-form3 commented Dec 6, 2021

Observed

A cortex rule with the following content always shows changes:

name: watchdog
rules:
- alert: watchdog
  expr: >
      series_a or on (label)
          (
            series_b
          )

Details

The Cortex API returns the alert in the following format (note the additional new line) and usage of literal style | instead of folded style >:

name: watchdog
rules:
    - alert: watchdog
      expr: |
        series_a or on (label)

            (
              series_b
            )

The current DiffSurpressFunc for the cortex_rule resource detects a different due to the additional newlines in the expr field.

Suggested fix

#14 updates the DiffSurpressFunc to use cortex-tools packages to compare rule groups. This could 1) be extended to normalise alerting expressions using Prometheus' promql parsing packages.

@janakerman-form3
Copy link
Contributor Author

After digging into this a bit more it seems to be an issue with go-yaml's handling of folded style yaml (i.e the > multi-line style) - go-yaml/yaml#804. Debugging the provider, the change in alert format can be seen before the alert is sent to the Cortex API.

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

No branches or pull requests

1 participant