Skip to content

Conversation

@ofek1weiss
Copy link
Contributor

@ofek1weiss ofek1weiss commented Jun 25, 2025

null

Summary by CodeRabbit

  • New Features

    • Added a CLI option to exclude alerts by tags, owners, models, statuses, or resource types in the monitor command.
  • Bug Fixes

    • Enhanced filter processing to support combined inclusion and exclusion criteria for alerts.
  • Tests

    • Added tests to validate the new exclusion filter functionality and updated existing tests accordingly.

@linear
Copy link

linear bot commented Jun 25, 2025

@github-actions
Copy link
Contributor

👋 @ofek1weiss
Thank you for raising your pull request.
Please make sure to add tests and document all user-facing changes.
You can do this by editing the docs files in this pull request.

@coderabbitai
Copy link

coderabbitai bot commented Jun 25, 2025

Walkthrough

A new --excludes CLI option was added to the monitor command to allow users to exclude alerts based on various criteria. The FiltersSchema.from_cli_params method and its usage were updated to handle both inclusion and exclusion filters. Corresponding unit tests were updated and expanded to verify this new exclusion functionality.

Changes

File(s) Change Summary
elementary/monitor/cli.py Added --excludes CLI option to monitor command; updated function signature and filter construction to support excludes.
elementary/monitor/data_monitoring/schema.py Modified FiltersSchema.from_cli_params to accept and process both include and exclude filters with different filter types.
tests/unit/monitor/data_monitoring/test_filters_schema.py Updated tests to pass excludes argument; added tests for exclude filter functionality and exclude statuses handling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant FiltersSchema

    User->>CLI: Run monitor command with --filters and/or --excludes
    CLI->>FiltersSchema: from_cli_params(filters, excludes)
    FiltersSchema->>FiltersSchema: Parse include (IS) and exclude (IS_NOT) filters
    FiltersSchema-->>CLI: Return FiltersSchema instance
    CLI-->>User: Display filtered monitoring results
Loading

Poem

A bunny with filters, both "in" and "out",
Now hops through alerts, with nary a doubt.
Exclude by a tag, or model, or owner—
The CLI’s smarter, a true springtime loner!
With tests all a-passing, the code’s feeling spry,
Hooray for new options—let’s give it a try! 🐇


📜 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 9126ae5 and 152b5b6.

📒 Files selected for processing (1)
  • elementary/monitor/cli.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • elementary/monitor/cli.py
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: code-quality
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
elementary/monitor/data_monitoring/schema.py (1)

184-184: Consider Python version compatibility for type annotations.

The type annotation list[tuple[str, FilterType]] requires Python 3.9+. If this project supports older Python versions, consider using List[Tuple[str, FilterType]] from the typing module instead.

-        all_filters: list[tuple[str, FilterType]] = []
+        all_filters: List[Tuple[str, FilterType]] = []
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 788ea52 and 9126ae5.

📒 Files selected for processing (3)
  • elementary/monitor/cli.py (3 hunks)
  • elementary/monitor/data_monitoring/schema.py (5 hunks)
  • tests/unit/monitor/data_monitoring/test_filters_schema.py (19 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
elementary/monitor/data_monitoring/schema.py

[refactor] 181-181: Too many local variables (16/15)

(R0914)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: code-quality
🔇 Additional comments (4)
elementary/monitor/cli.py (1)

272-280: LGTM! Well-structured excludes option implementation.

The new --excludes CLI option follows the established patterns:

  • Mirrors the --filters option structure appropriately
  • Uses a clear alias (-ex) and comprehensive help text
  • Correctly integrates with the existing filtering logic

The function signature and conditional logic updates are properly coordinated.

Also applies to: 317-317, 357-358

elementary/monitor/data_monitoring/schema.py (1)

181-189: Excellent implementation of combined inclusion/exclusion filtering.

The logic correctly:

  • Combines both filter types with appropriate FilterType enum values
  • Maintains the existing processing loop structure while adding type awareness
  • Preserves default status filters when only exclusion filters are provided (lines 252-253)

This ensures that users can mix inclusion and exclusion filters effectively while maintaining backward compatibility.

Also applies to: 199-253

tests/unit/monitor/data_monitoring/test_filters_schema.py (2)

8-9: Good mechanical updates to accommodate new method signature.

All existing test calls are correctly updated to include the cli_excludes parameter, maintaining test compatibility with the updated from_cli_params method signature.

Also applies to: 22-23, 35-36, 48-49, 64-65, 77-78, 90-91, 106-107, 119-120, 132-133, 149-150, 154-155, 159-160, 163-164, 173-174, 183-184, 197-198, 202-203, 207-208, 211-212, 224-225, 237-238, 253-254, 267-268


281-297: Excellent test coverage for exclude functionality.

The new tests effectively validate:

  • test_exclude_filters: Mixed inclusion/exclusion filters with correct FilterType assignment (IS vs IS_NOT)
  • test_exclude_statuses_filters: Edge case where only exclusion filters are provided, ensuring default status filters are preserved

These tests provide comprehensive coverage of the new exclude functionality and important edge cases.

Also applies to: 299-313

Co-authored-by: Mika Kerman <[email protected]>
@ofek1weiss ofek1weiss temporarily deployed to elementary_test_env June 25, 2025 11:49 — with GitHub Actions Inactive
@ofek1weiss ofek1weiss merged commit ded6ea5 into master Jun 25, 2025
5 checks passed
@ofek1weiss ofek1weiss deleted the ele-4677-add-exclude-option-to-edr-monitor branch June 25, 2025 12:33
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.

3 participants