Skip to content

feature/add-tg-severity-setting - #585

Merged
Andrei Kvapil (kvaps) merged 4 commits into
cozystack:mainfrom
klinch0:feature/add-tg-severity-setting
Jan 17, 2025
Merged

feature/add-tg-severity-setting#585
Andrei Kvapil (kvaps) merged 4 commits into
cozystack:mainfrom
klinch0:feature/add-tg-severity-setting

Conversation

@klinch0

@klinch0 klinch0 commented Jan 16, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added option to disable Telegram alerts for specific severity levels in the Monitoring Hub.
  • Documentation

    • Updated README with new parameter alerta.alerts.telegram.disabledSeverity.
  • Chores

    • Bumped monitoring package version from 1.6.1 to 1.7.0.

@coderabbitai

coderabbitai Bot commented Jan 16, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request updates the monitoring package's configuration by changing the version from 1.6.1 to 1.7.0 and introducing a new parameter, disabledSeverity, which allows users to specify severity levels for which alerts will not be generated. The modifications are reflected in several files, including Chart.yaml, README.md, values.yaml, values.schema.json, and alerta.yaml, enhancing the application's configuration capabilities.

Changes

File Change Summary
packages/extra/monitoring/Chart.yaml Version updated from 1.6.1 to 1.7.0
packages/extra/monitoring/README.md Added documentation for new alerta.alerts.telegram.disabledSeverity parameter
packages/extra/monitoring/templates/alerta/alerta.yaml Added new environment variable TELEGRAM_DISABLE_NOTIFICATION_SEVERITY
packages/extra/monitoring/values.schema.json Added disabledSeverity property to Telegram alerts configuration
packages/extra/monitoring/values.yaml Added new disabledSeverity parameter under alerta.alerts.telegram
packages/extra/versions_map Updated version mapping for monitoring package from HEAD to specific commit hash for 1.6.1 and added new entry for 1.7.0

Possibly related PRs

Suggested labels

enhancement, size:L

Suggested reviewers

  • kvaps

Poem

🐰 A Rabbit's Ode to Telegram Alerts 🚨

Severity levels, now under control,
With just a comma, we'll make alerts whole!
From info to warning, silence they'll be,
A monitoring magic, as clever as me!
Hop hop, config change, notification's delight! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/extra/monitoring/README.md (1)

15-15: Format the URL as a proper markdown link.

Convert the bare URL to a proper markdown link for better readability and to follow markdown best practices.

-| `alerta.alerts.telegram.chatID`           | specify multiple ID's separated by comma. Get yours in https://t.me/chatid_echo_bot                       | `""`   |
+| `alerta.alerts.telegram.chatID`           | specify multiple ID's separated by comma. Get yours in [chatid_echo_bot](https://t.me/chatid_echo_bot)    | `""`   |
🧰 Tools
🪛 Markdownlint (0.37.0)

15-15: null
Bare URL used

(MD034, no-bare-urls)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4e68e65 and af8be3e.

📒 Files selected for processing (6)
  • packages/extra/monitoring/Chart.yaml (1 hunks)
  • packages/extra/monitoring/README.md (1 hunks)
  • packages/extra/monitoring/templates/alerta/alerta.yaml (1 hunks)
  • packages/extra/monitoring/values.schema.json (1 hunks)
  • packages/extra/monitoring/values.yaml (1 hunks)
  • packages/extra/versions_map (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/extra/monitoring/Chart.yaml
🧰 Additional context used
🪛 Markdownlint (0.37.0)
packages/extra/monitoring/README.md

15-15: null
Bare URL used

(MD034, no-bare-urls)

🔇 Additional comments (6)
packages/extra/versions_map (1)

25-26: LGTM! Version mapping updates look correct.

The version mapping follows the established pattern, with 1.6.1 properly mapped to a specific commit and 1.6.2 pointing to HEAD.

packages/extra/monitoring/README.md (1)

16-16: LGTM! New parameter documentation is clear and follows the established format.

The documentation for alerta.alerts.telegram.disabledSeverity clearly explains its purpose and expected format.

packages/extra/monitoring/values.schema.json (1)

54-58: LGTM! Schema definition for new property is well-structured.

The schema definition for disabledSeverity follows JSON Schema standards and properly aligns with the documentation.

packages/extra/monitoring/values.yaml (1)

81-86: LGTM! Parameter documentation and example are clear.

The new parameter is well-documented with clear examples of its usage.

packages/extra/monitoring/templates/alerta/alerta.yaml (2)

119-120: Verify conditional block's behavior with empty values.

Since this is within a conditional block that checks for chatID and token, verify that empty disabledSeverity values don't cause issues.

Run this script to check the template rendering with various value combinations:

✅ Verification successful

Empty values for disabledSeverity are safely handled within the Telegram conditional block

The variable is only included when both chatID and token are present, and empty values are handled gracefully by Helm's templating engine. No issues found with the current implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Test template rendering with different value combinations
# Note: This assumes helm is available in the environment

# Create test values files
cat > test1.yaml << EOF
alerta:
  alerts:
    telegram:
      chatID: "123"
      token: "abc"
      disabledSeverity: ""
EOF

cat > test2.yaml << EOF
alerta:
  alerts:
    telegram:
      chatID: "123"
      token: "abc"
      disabledSeverity: "warning,info"
EOF

# Test template rendering
for f in test1.yaml test2.yaml; do
  echo "Testing with $f:"
  helm template -f "$f" . | grep TELEGRAM_DISABLE_NOTIFICATION_SEVERITY
done

Length of output: 543


Script:

#!/bin/bash
# Get the context around the TELEGRAM_DISABLE_NOTIFICATION_SEVERITY variable
rg -B 5 -A 5 "TELEGRAM_DISABLE_NOTIFICATION_SEVERITY" packages/extra/monitoring/templates/alerta/alerta.yaml

# Also check for any telegram-related conditional blocks
rg "telegram" packages/extra/monitoring/templates/alerta/alerta.yaml

Length of output: 1193


119-120: LGTM! Consider documenting the format.

The implementation correctly adds the new environment variable within the Telegram configuration block. The variable name follows the established naming convention, and the value is properly templated from Helm values.

Please ensure the format of disabledSeverity is documented in the README.md. Run this command to verify:

## @param alerta.alerts.telegram.disabledSeverity list of severity without alerts, separated comma like: "informational,warning"
## example:
## telegram:
## token: "7262461387:AAGtwq16iwuVtWtzoN6TUEMpF00fpC9Xz34"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Replace the example Telegram bot token with a placeholder.

The example appears to contain a real bot token. Replace it with a placeholder to avoid potential security risks.

-    ##     token: "7262461387:AAGtwq16iwuVtWtzoN6TUEMpF00fpC9Xz34"
+    ##     token: "123456789:ABCdefGHIjklMNOpqrsTUVwxyz1234567890"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## token: "7262461387:AAGtwq16iwuVtWtzoN6TUEMpF00fpC9Xz34"
## token: "123456789:ABCdefGHIjklMNOpqrsTUVwxyz1234567890"

@klinch0
klinch0 force-pushed the feature/add-tg-severity-setting branch from af8be3e to 81d8e3d Compare January 16, 2025 13:39
@dosubot dosubot Bot added the size/M This PR changes 30-99 lines, ignoring generated files label Jan 16, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/extra/monitoring/README.md (2)

15-15: Format the bare URL as a proper Markdown link.

To comply with Markdown best practices and fix the markdownlint warning, format the URL as a proper Markdown link.

-| `alerta.alerts.telegram.chatID`           | specify multiple ID's separated by comma. Get yours in https://t.me/chatid_echo_bot                       | `""`   |
+| `alerta.alerts.telegram.chatID`           | specify multiple ID's separated by comma. Get yours in [chatid_echo_bot](https://t.me/chatid_echo_bot)    | `""`   |
🧰 Tools
🪛 Markdownlint (0.37.0)

15-15: null
Bare URL used

(MD034, no-bare-urls)


16-16: Enhance documentation with valid severity values.

The documentation should list the valid severity values that can be disabled to help users configure the setting correctly.

-| `alerta.alerts.telegram.disabledSeverity` | list of severity without alerts, separated comma like: "informational,warning"                            | `""`   |
+| `alerta.alerts.telegram.disabledSeverity` | list of severity levels to disable alerts for (valid values: critical, major, minor, warning, informational, debug), comma-separated | `""`   |
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between af8be3e and 81d8e3d.

📒 Files selected for processing (6)
  • packages/extra/monitoring/Chart.yaml (1 hunks)
  • packages/extra/monitoring/README.md (1 hunks)
  • packages/extra/monitoring/templates/alerta/alerta.yaml (1 hunks)
  • packages/extra/monitoring/values.schema.json (1 hunks)
  • packages/extra/monitoring/values.yaml (1 hunks)
  • packages/extra/versions_map (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/extra/monitoring/values.schema.json
  • packages/extra/versions_map
  • packages/extra/monitoring/templates/alerta/alerta.yaml
  • packages/extra/monitoring/Chart.yaml
🧰 Additional context used
🪛 Markdownlint (0.37.0)
packages/extra/monitoring/README.md

15-15: null
Bare URL used

(MD034, no-bare-urls)

🔇 Additional comments (1)
packages/extra/monitoring/values.yaml (1)

84-84: Replace the example Telegram bot token with a placeholder.

The example appears to contain a real bot token. Replace it with a placeholder to avoid potential security risks.

Comment on lines +81 to +86
## @param alerta.alerts.telegram.disabledSeverity list of severity without alerts, separated comma like: "informational,warning"
## example:
## telegram:
## token: "7262461387:AAGtwq16iwuVtWtzoN6TUEMpF00fpC9Xz34"
## chatID: "-4520856007"
## disabledSeverity: "informational,warning"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Add enum validation for severity levels in schema.

The disabledSeverity parameter should be updated in values.schema.json to validate against known severity levels:

  • Add pattern validation to ensure comma-separated format
  • Add enum validation for individual severity values: informational, warning, critical, major, ok, alert
🔗 Analysis chain

Add validation for severity values.

The disabledSeverity parameter should be validated to ensure only valid severity levels are accepted. Consider adding validation in the schema or application code.

Let's check if there's any validation in place:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for severity validation in the codebase
rg -i "severity.*valid" --type yaml --type json
rg -i "severity.*check" --type yaml --type json

# Search for schema definition
rg -i "disabledSeverity" --type json

Length of output: 464


Script:

#!/bin/bash
# Check the schema definition for disabledSeverity
rg -A 10 -B 2 "disabledSeverity" packages/extra/monitoring/values.schema.json

# Search for severity level definitions
rg -i "severity.*=|severity.*:|severity.*\[" --type ts --type js --type yaml

# Look for severity in configuration files
fd -e yaml -e yml -X rg -i "severity.*:" -A 3

Length of output: 73721

@dosubot dosubot Bot added the kind/feature Categorizes issue or PR as related to a new feature label Jan 16, 2025

@kvaps Andrei Kvapil (kvaps) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@kvaps
Andrei Kvapil (kvaps) merged commit e037cb0 into cozystack:main Jan 17, 2025
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature lgtm This PR has been approved by a maintainer size/M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants