alertmanager icon indicating copy to clipboard operation
alertmanager copied to clipboard

feat(cli): add grouping verification to routing test command

Open heartwilltell opened this issue 11 months ago • 0 comments

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:

  1. Simple receiver verification (backward compatible):

amtool config routes test --verify.receivers-grouping="team-A-opsgenie,team-B-opsgenie"

  1. Receiver with grouping verification:

amtool config routes test --verify.receivers-grouping="team-A-opsgenie[cluster,severity]"

  1. 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]

heartwilltell avatar Jan 16 '25 14:01 heartwilltell