-- Opt in by adding this file to rules; existing window rules keep their original behavior. rule "database_health" do on "db.transaction" where not incomplete group_by service, db.system window "60s" when count() >= 20 and ratio(error) >= 0.10 lifecycle do trigger_windows 2 recovery_windows 2 recover_when count() >= 20 and ratio(error) <= 0.05 repeat "5m" end emit "database.health" do severity = "warning" message = "Database error rate" requests = count() error_rate = ratio(error) end end