feat(cli): add grouping verification to routing test command
Closes: #3003
Add grouping verification to amtool config routes test
This 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 to amtool config routes test that allows users to specify both receivers and their expected grouping labels. The flag supports:
- Simple receiver verification (backward compatible):
amtool config routes test --verify.receivers-grouping="team-A-opsgenie,team-B-opsgenie"
- Receiver with grouping verification:
amtool config routes test --verify.receivers-grouping="team-A-opsgenie[cluster,severity]"
- Multiple grouping configurations for the same receiver:
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]