Feature: Auto-create incidents after 10 failed checks with rich descriptions

- Add description and failed_check_count fields to incidents table
- Update handleIncident() to use configurable threshold (default 10 checks)
- Auto-generate incident description with:
  - Number of consecutive failures
  - Last error message/reason
  - First failure timestamp
- Add API endpoints: GET/POST /api/settings/incident-threshold
- Add UI settings field to configure incident failure threshold
- Server: Get threshold from database settings (persistent across restarts)
- Default threshold: 10 consecutive failed checks per resource
This commit is contained in:
nmemmert committed 2025-12-16 13:24:20 -05:00
1 parent 6b00530a89
commit 5330c8932f
10 files changed
+106 -29

No files matched your search

+22 -1
View File
@@ -245,9 +245,30 @@ try {
}
}
// Settings for data retention
// Add description column to incidents for incident summaries
try {
db.prepare("ALTER TABLE incidents ADD COLUMN description TEXT").run();
console.log('[DB] Added description column to incidents');
} catch (err) {
if (err.message.includes('duplicate')) {
console.log('[DB] description column already exists');
}
}
// Add failed_check_count to incidents to track consecutive failures at creation time
try {
db.prepare("ALTER TABLE incidents ADD COLUMN failed_check_count INTEGER DEFAULT 0").run();
console.log('[DB] Added failed_check_count column to incidents');
} catch (err) {
if (err.message.includes('duplicate')) {
console.log('[DB] failed_check_count column already exists');
}
}
// Settings for data retention and incident thresholds
try {
db.prepare("INSERT OR IGNORE INTO settings (key, value) VALUES ('retention_days', '30')").run();
db.prepare("INSERT OR IGNORE INTO settings (key, value) VALUES ('incident_failure_threshold', '10')").run();
} catch (err) {}
// Helpful indexes for time-range queries