fix: spurious health alerts, show rotated logs, clear history button

app.py:
- Alert logic now checks status.running (container up/down) instead of healthy
  (which requires connectivity tests) — services are only alerted when actually down
- Add POST /api/health/history/clear endpoint to reset history + alert counters

log_manager.py:
- get_all_log_file_infos: include rotated backup files (*.log.1, *.log.2 ...) in listing,
  marked with backup=true so UI can dim them and hide rotate button

api.js: add monitoringAPI.clearHealthHistory

Logs page:
- Health History: add Clear button with confirmation
- File panel: show full filename (including .log.1 backups), explain host path and naming,
  hide rotate button for backup files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-21 03:05:04 -04:00
parent a5381b2ebc
commit 8e1814c7d2
4 changed files with 61 additions and 40 deletions
+22 -12
View File
@@ -520,19 +520,29 @@ class LogManager:
}
def get_all_log_file_infos(self) -> List[Dict[str, Any]]:
"""Return size/mtime info for all service log files."""
"""Return size/mtime info for active and rotated service log files."""
results = []
for log_file in sorted(self.log_dir.glob('*.log')):
try:
stat = log_file.stat()
results.append({
'name': log_file.stem,
'file': log_file.name,
'size': stat.st_size,
'modified': datetime.fromtimestamp(stat.st_mtime).isoformat(),
})
except Exception:
pass
# Active logs (*.log) then rotated backups (*.log.1, *.log.2, ...)
patterns = ['*.log', '*.log.*']
seen = set()
for pattern in patterns:
for log_file in sorted(self.log_dir.glob(pattern)):
if log_file in seen or log_file.suffix == '.gz':
continue
seen.add(log_file)
try:
stat = log_file.stat()
name = log_file.name
is_backup = not name.endswith('.log')
results.append({
'name': log_file.stem.split('.')[0], # service name
'file': name,
'size': stat.st_size,
'modified': datetime.fromtimestamp(stat.st_mtime).isoformat(),
'backup': is_backup,
})
except Exception:
pass
return results
def compress_old_logs(self):