Skip to content

Conversation

@Nepomuk5665
Copy link
Contributor

Summary

This PR implements issue #509, allowing users to specify regex patterns in the keep and strip parameters for the promql/aggregate check.

Changes

  • Modified AggregationCheck to accept a regex pattern for label matching instead of requiring literal strings
  • Added extractLiteralLabels helper to extract individual labels from simple alternation patterns like job|instance
  • Updated config validation to verify regex patterns in keep/strip lists
  • For simple literal patterns, the behavior is fully backward compatible
  • For regex patterns, all labels in src.Labels that match the pattern are checked

Example Usage

rule {
  match {
    kind = "alerting"
  }

  aggregate ".+" {
    keep = ["job|instance"]  # Preserve either job or instance labels
  }
}

Fixes #509

This change implements issue cloudflare#509, allowing users to specify regex patterns
in the keep and strip parameters for the promql/aggregate check.

Changes:
- Modified AggregationCheck to accept a regex pattern for label matching
  instead of a literal string
- Added extractLiteralLabels helper to extract individual labels from
  simple alternation patterns like 'job|instance'
- Updated config validation to verify regex patterns in keep/strip lists
- For simple literal patterns, the behavior is fully backward compatible
- For regex patterns, all labels in src.Labels that match the pattern
  are checked

Example usage:
  aggregate ".+" {
    keep = ["job|instance"]  # Preserve either job or instance labels
  }

Fixes cloudflare#509
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.

Allow regex to keep for promql/aggregate

1 participant