Assuming the alert conditions can be detected with a PromQL expression (edit: this was verified in T432863: Define alert conditions in Prometheus (if possible)), I can think of 3 options:
Extend jobs-emailer to receive webhooks from alertmanager (or poll alertmanager)(discarded, jobs-emailer is too specific and tied to k8s events)- Create a new service that receives webhooks from alertmanager (or that polls alertmanager)
- EDIT: a variant of this option was chosen in the discussion below: create a new service that polls Prometheus directly
Let alertmanager send the emails directly, no extra service needed(discarded in the discussion below, it would not give enough flexibility)
We already have email aliases that map to all maintainers of a tool, emails can go to that address and not to individual maintainers.
- Letting individual users opt in or out of alerts would be useful, but would also add significant complexity. Let’s keep it out of scope for this task.
If a service remains down for days, how many emails should we send? Just one? One every 24 hours? How do we keep track of emails sent to avoid sending too many?
- Can we leverage alertmanager's repeat_interval for this?
- EDIT: reminder emails every 24 hours were implemented in the new service, without relying on alertmanager
- Multi-tool question: will maintainers receive one alert per each tool or will there be some sort of grouping?
- EDIT: No grouping for now, as we are sending emails using the alias tools.toolname@toolforge.org, so if a user is a maintainer of multiple tools that are alerting, they will receive one email per tool
