Background
In the parent task T432863: Define alert conditions in Prometheus (if possible) I would like to add three new alerts to https://gitlab.wikimedia.org/repos/cloud/toolforge/alerts. These new alerts are not tagged with team: wmcs as they are destined to tool maintainers, not toolforge admins. Eventually, the plan is to let tool maintainers receive email notifications for these alerts (T432865: Email tool maintainers when an alert condition is detected).
The issue
Currently, alerts defined in https://gitlab.wikimedia.org/repos/cloud/toolforge/alerts get tagged with project: tools (where?) and the metricsinfra config in metricsinfra-controller-3 (MariaDB database) routes all alerts for that project to the default_contact_group_id, which includes the cloud-admin-feed mailing list and to #wikimedia-cloud-feed on IRC:
MariaDB [prometheusconfig]> select * from projects where name="tools"; +----+--------------+-------+--------------------------+-----------------------------------------------------+------------------+ | id | openstack_id | name | default_contact_group_id | acl_group | extra_labels | +----+--------------+-------+--------------------------+-----------------------------------------------------+------------------+ | 12 | tools | tools | 1 | cn=tools.admin,ou=servicegroups,dc=wikimedia,dc=org | {"team": "wmcs"} | +----+--------------+-------+--------------------------+-----------------------------------------------------+------------------+ 1 row in set (0.001 sec) MariaDB [prometheusconfig]> SELECT * FROM contact_groups c JOIN contact_group_members m ON c.id=m.contact_group_id WHERE c.id = 1; +----+------------+------------+----+------------------+-------+--------------------------------------+ | id | name | project_id | id | contact_group_id | type | value | +----+------------+------------+----+------------------+-------+--------------------------------------+ | 1 | cloud-feed | 10 | 1 | 1 | EMAIL | cloud-admin-feed@lists.wikimedia.org | | 1 | cloud-feed | 10 | 2 | 1 | IRC | #wikimedia-cloud-feed | +----+------------+------------+----+------------------+-------+--------------------------------------+ 2 rows in set (0.002 sec)
What I would like to achieve is to only route to cloud-admin-feed@ and IRC the alerts with team: wmcs, instead of all alerts with project: tools.
Possible solutions
I can think of two possible solutions:
- In the metricsinfra projects table (see above), edit the line for project tools, removing {"team": "wmcs"} from extra_labels and setting default_contact_group_id to NULL. Then add a custom route in alertmanager.yml.epp to route alerts with team: wmcs to IRC and cloud-admin-feed@ (similar to the existing route sending alerts to victorops).
- Extend the SQL structure to support an additional notification_filter where an optional filter can be specified to determine which alerts are sent to the contact groups (in this case the notification_filter would be team: wmcs)