Tag incidents with categories for summaries
This commit is contained in:
@@ -32,7 +32,7 @@ async def _handle_alerts(msg: Message, action: str, args: list[str]):
|
||||
key = f"test:{level}:{int(time.time())}"
|
||||
await notify(bot, msg.chat.id, f"[TEST] {level.upper()} alert", level=level, key=key, category="test")
|
||||
await msg.answer(f"Sent test alert: {level}")
|
||||
log_incident(cfg, f"alert_test level={level} by {msg.from_user.id}")
|
||||
log_incident(cfg, f"alert_test level={level} by {msg.from_user.id}", category="test")
|
||||
return
|
||||
|
||||
if action == "mute":
|
||||
@@ -49,7 +49,7 @@ async def _handle_alerts(msg: Message, action: str, args: list[str]):
|
||||
until = set_mute(category, minutes * 60)
|
||||
dt = datetime.fromtimestamp(until, tz=timezone.utc).astimezone()
|
||||
await msg.answer(f"🔕 Muted {category} for {minutes}m (until {dt:%Y-%m-%d %H:%M:%S})")
|
||||
log_incident(cfg, f"alert_mute category={category} minutes={minutes} by {msg.from_user.id}")
|
||||
log_incident(cfg, f"alert_mute category={category} minutes={minutes} by {msg.from_user.id}", category=category)
|
||||
return
|
||||
|
||||
if action == "unmute":
|
||||
@@ -59,7 +59,7 @@ async def _handle_alerts(msg: Message, action: str, args: list[str]):
|
||||
category = args[0].lower()
|
||||
clear_mute(category)
|
||||
await msg.answer(f"🔔 Unmuted {category}")
|
||||
log_incident(cfg, f"alert_unmute category={category} by {msg.from_user.id}")
|
||||
log_incident(cfg, f"alert_unmute category={category} by {msg.from_user.id}", category=category)
|
||||
return
|
||||
|
||||
if action in ("list", "mutes"):
|
||||
|
||||
@@ -367,7 +367,7 @@ async def schedule_backup(msg: Message):
|
||||
await msg.answer(f"🕓 Backup queued (#{pos})", reply_markup=backup_kb)
|
||||
try:
|
||||
from services.incidents import log_incident
|
||||
log_incident(cfg, f"backup_queued by {msg.from_user.id}")
|
||||
log_incident(cfg, f"backup_queued by {msg.from_user.id}", category="backup")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ async def cmd_docker_status(msg: Message):
|
||||
lines.append(f"{icon} {alias}: {status} ({up})")
|
||||
|
||||
await msg.answer("\n".join(lines), reply_markup=docker_kb)
|
||||
log_incident(cfg, f"docker_status by {msg.from_user.id}")
|
||||
log_incident(cfg, f"docker_status by {msg.from_user.id}", category="docker")
|
||||
|
||||
except Exception as e:
|
||||
# ⬅️ КРИТИЧЕСКИ ВАЖНО
|
||||
@@ -122,7 +122,7 @@ async def docker_health(msg: Message):
|
||||
out_line = entry.get("Output", "").strip()
|
||||
lines.append(f"- {ts} rc={exitc} {out_line}")
|
||||
await msg.answer("\n".join(lines), reply_markup=docker_kb)
|
||||
log_incident(cfg, f"docker_health alias={alias} by {msg.from_user.id}")
|
||||
log_incident(cfg, f"docker_health alias={alias} by {msg.from_user.id}", category="docker")
|
||||
|
||||
|
||||
@dp.message(F.text == "📈 Stats")
|
||||
|
||||
Reference in New Issue
Block a user