fix(alerts): an alert on a count says how many of what, and names them (#6400)
"swarm services short on swarm is 6." becomes "6 swarm services are short of their replicas.", with a Which line naming each service and how many of its tasks run. The swarm figures get labels, and the counting figures (swarm, mounts, drives, updates) read as sentences in the email, its subject and the Alerts page. A plugin names what its count counts through core.alerts.names_behind; the Docker plugin does for the three swarm figures, from the stored swarm. Webhooks get alert.which too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -62,6 +62,18 @@ def test_no_reading_yet_is_said_not_shown_as_a_number():
|
||||
assert _said(says) == "CPU on web-1 has no reading yet (> 90%), firing for 3m"
|
||||
|
||||
|
||||
def test_a_count_says_how_many_of_what():
|
||||
"""#6400: "swarm services short on swarm is 6" named nothing and wasn't a sentence."""
|
||||
now = datetime.now(timezone.utc)
|
||||
swarm = alert_sentence(_rule("swarm_services_short", threshold=0.0, resource="swarm"), "firing", 6.0,
|
||||
now - timedelta(minutes=4), now)
|
||||
assert swarm["resource"] == "6 swarm services are short of their replicas"
|
||||
assert _said(swarm) == "6 swarm services are short of their replicas (> 0), firing for 4m"
|
||||
host = alert_sentence(_rule("mounts_stalled", threshold=0.0, resource="nas"), "firing", 1.0,
|
||||
now - timedelta(minutes=4), now)
|
||||
assert (host["resource"], _said(host)) == ("nas", "1 mount isn't answering on nas (> 0), firing for 4m")
|
||||
|
||||
|
||||
def test_a_silent_series_says_how_long_it_has_been_quiet():
|
||||
now = datetime.now(timezone.utc)
|
||||
says = alert_sentence(_rule(), "no_data", 50.0, now - timedelta(minutes=20), now)
|
||||
|
||||
Reference in New Issue
Block a user