-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feat(cli): add grouping verification to routing test command #4208
Open
heartwilltell
wants to merge
17
commits into
prometheus:main
Choose a base branch
from
heartwilltell:alert-grouping-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
heartwilltell
force-pushed
the
alert-grouping-test
branch
9 times, most recently
from
January 20, 2025 15:42
001fe91
to
a0a4de8
Compare
…0 and use `version.ComponentUserAgent` Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Signed-off-by: heartwilltell <heartwilltell@gmail.com>
Signed-off-by: heartwilltell <heartwilltell@gmail.com>
Signed-off-by: heartwilltell <heartwilltell@gmail.com>
- Added `expectedReceiversGroup` field to `routingShow` struct for grouping verification. - Updated command flags to include `--verify.receivers-grouping` for specifying receivers and their groupings. - Implemented `parseReceiversWithGrouping` function to handle input parsing for receivers with optional groupings. - Enhanced `routingTestAction` to validate both receivers and their groupings against resolved values. This update improves the routing test command's ability to verify complex receiver configurations. Signed-off-by: heartwilltell <heartwilltell@gmail.com>
- Enhanced documentation for the receiversGrouping field in the routingShow struct to clarify its purpose. - No functional changes were made; this update focuses on code readability and maintainability. Signed-off-by: heartwilltell <heartwilltell@gmail.com>
Signed-off-by: heartwilltell <heartwilltell@gmail.com>
- Improved the `parseReceiversWithGrouping` function to correctly handle commas within square brackets, allowing for more complex receiver formats. - Updated the grouping validation logic to ensure proper formatting and trimming of group names. - Enhanced the `routingTestAction` method to provide clearer warnings when expected and actual receivers do not match, including detailed output of discrepancies. This update increases the robustness of receiver parsing and validation in the routing test command. Signed-off-by: heartwilltell <heartwilltell@gmail.com>
…racket handling - Updated the `parseReceiversWithGrouping` function to remove spaces around commas for cleaner input processing. - Enhanced bracket handling to correctly manage nested groupings, ensuring proper parsing of receiver lists. - Improved error messaging for invalid grouping formats to provide clearer feedback. These changes enhance the robustness and usability of the receiver parsing functionality. Signed-off-by: heartwilltell <heartwilltell@gmail.com>
Signed-off-by: heartwilltell <heartwilltell@gmail.com>
Signed-off-by: heartwilltell <heartwilltell@gmail.com>
- Introduced `removeSpacesAroundCommas` function to streamline input processing by removing unnecessary spaces around commas. - Improved `parseReceiversWithGrouping` to better handle nested groupings and enhance error messaging for invalid formats. - Added `sortGroupLabels` function to return sorted group labels for improved consistency in output. - Updated `verifyReceivers` and `verifyReceiversGrouping` functions to provide clearer error messages when expected and actual receivers do not match. - Enhanced `formatOutput` to generate a more structured output of receivers and their groupings. These changes improve the robustness and usability of the receiver parsing and validation functionality in the routing test command. Signed-off-by: heartwilltell <heartwilltell@gmail.com>
heartwilltell
force-pushed
the
alert-grouping-test
branch
from
January 20, 2025 15:43
a0a4de8
to
7fb8ba3
Compare
…thGrouping` - Removed redundant variable declarations for `inBrackets` and `bracketCount` by initializing them directly in the variable declaration block. - Simplified the conditional logic for handling commas outside of brackets, improving code readability and maintainability. These changes enhance the clarity and efficiency of the receiver parsing functionality. Signed-off-by: heartwilltell <heartwilltell@gmail.com>
heartwilltell
force-pushed
the
alert-grouping-test
branch
from
January 20, 2025 15:49
d4dbc59
to
623dcc0
Compare
…iversGrouping` - Introduced a new map to store expected groupings for base receivers, improving the logic for matching actual groups against expected ones. - Simplified the matching process by eliminating unnecessary checks and enhancing error messaging for unmatched groupings. - Improved clarity of warnings when no matching grouping is found, providing detailed output of expected groups. These changes enhance the efficiency and readability of the receiver grouping verification process in the routing test command. Signed-off-by: heartwilltell <heartwilltell@gmail.com>
heartwilltell
force-pushed
the
alert-grouping-test
branch
from
January 20, 2025 21:51
50e31ef
to
10a3628
Compare
…ReceiversGrouping` - Updated error messages in `parseLabelSet` to start with a capital letter for consistency. - Enhanced the warning message in `verifyReceiversGrouping` to format the output more clearly, ensuring better readability of expected groupings when no match is found. These changes improve the clarity and consistency of error handling in the routing test command. Signed-off-by: heartwilltell <heartwilltell@gmail.com>
heartwilltell
force-pushed
the
alert-grouping-test
branch
from
January 20, 2025 22:02
de1f704
to
6e4384c
Compare
…ing` - Improved the logic for matching actual groupings against expected ones by sorting both expected and actual groups before comparison. - Added comments for clarity, ensuring that the purpose of each step in the verification process is well-documented. - This update enhances the accuracy and readability of the receiver grouping verification process in the routing test command. Signed-off-by: heartwilltell <heartwilltell@gmail.com>
heartwilltell
force-pushed
the
alert-grouping-test
branch
from
January 20, 2025 22:29
1a4eb95
to
a6fabf5
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #3003
Add grouping verification to
amtool
config routes testThis PR adds the ability to verify alert grouping configuration when testing routes with
amtool
. The new functionality helps users ensure that alerts are not only routed to the correct receivers but are also grouped as expected.Changes
Added a new flag
--verify.receivers-grouping
toamtool config routes test
that allows users to specify both receivers and their expected grouping labels. The flag supports:amtool config routes test --verify.receivers-grouping="team-A-opsgenie,team-B-opsgenie"
amtool config routes test --verify.receivers-grouping="team-A-opsgenie[cluster,severity]"
amtool config routes test --verify.receivers-grouping="team-A-opsgenie[cluster,severity],team-A-opsgenie[cluster,severity,alertname]"
Example Usage
Test routing and grouping
amtool config routes test --config.file=alertmanager.yaml \ --verify.receivers-grouping="wire-team-opsgenie[env,cluster,priority]" \ team=wire
Output shows both the receiver and its grouping
wire-team-opsgenie[env,cluster,priority]