diff --git a/config/default.php b/config/default.php index 5242fc1..b6373d6 100644 --- a/config/default.php +++ b/config/default.php @@ -10,10 +10,10 @@ return [ 'sources' => [], 'rules' => [ [ - 'name' => 'PHP Error', - 'pattern' => '/PHP (Fatal|Parse|Catchable|Notice|Warning)/i', - 'severity' => 'warning', - 'rate_limit_seconds' => 60, + 'name' => 'PHP Fatal Error', + 'pattern' => '/PHP Fatal/i', + 'severity' => 'critical_high', + 'rate_limit_seconds' => 30, ], [ 'name' => 'PHP Exception', @@ -21,6 +21,17 @@ return [ 'severity' => 'critical', 'rate_limit_seconds' => 30, ], + [ + 'name' => 'PHP Parse Error', + 'pattern' => '/PHP Parse/i', + 'severity' => 'critical', + ], + [ + 'name' => 'PHP Warning', + 'pattern' => '/PHP (Warning|Notice)/i', + 'severity' => 'warning', + 'rate_limit_seconds' => 60, + ], [ 'name' => 'HTTP 5xx', 'pattern' => '/" (50[0-9]) /', @@ -29,30 +40,41 @@ return [ [ 'name' => 'HTTP 4xx', 'pattern' => '/" (4[0-9]{2}) /', - 'severity' => 'warning', + 'severity' => 'warning_low', 'rate_limit_seconds' => 60, ], [ 'name' => 'Failed Login', 'pattern' => '/Failed (login|password|authentication)/i', - 'severity' => 'critical', + 'severity' => 'critical_low', ], [ 'name' => 'Out of Memory', - 'pattern' => '/out of memory/i', - 'severity' => 'critical', + 'pattern' => '/out of memory|OutOfMemory/i', + 'severity' => 'emergency', 'rate_limit_seconds' => 60, ], [ 'name' => 'Connection Refused', 'pattern' => '/Connection (refused|reset|timed? out)/i', - 'severity' => 'warning', + 'severity' => 'warning_high', ], [ 'name' => 'Disk Space', 'pattern' => '/disk (full|space|usage|low)/i', - 'severity' => 'warning', + 'severity' => 'critical_low', 'rate_limit_seconds' => 300, ], + [ + 'name' => 'Service Started', + 'pattern' => '/service started|daemon started|ready to serve/i', + 'severity' => 'notice', + ], + [ + 'name' => 'Slow Query', + 'pattern' => '/slow (query|request|response)/i', + 'severity' => 'warning_high', + 'rate_limit_seconds' => 60, + ], ], ]; \ No newline at end of file diff --git a/public/index.html b/public/index.html index 16f19a0..e5f702d 100644 --- a/public/index.html +++ b/public/index.html @@ -127,9 +127,17 @@ pre.raw-line { background: var(--bs-tertiary-bg); padding: .75rem; border-radius
+ + + + + + + +
@@ -533,8 +549,15 @@ function toast(msg, type = 'success') { } function severityBadge(s) { - const map = { critical: 'danger', warning: 'warning', info: 'info' }; - return `${s}`; + const map = { + debug: 'secondary', info: 'info', notice: 'info', + warning_low: 'warning', warning: 'warning', warning_high: 'warning', + error: 'danger', + critical_low: 'danger', critical: 'danger', critical_high: 'danger', + emergency: 'dark', + }; + const label = s.replace(/_/g, ' '); + return `${label}`; } function statusBadge(s) { @@ -593,8 +616,17 @@ async function loadDashboard() { } const chartEl = document.getElementById('chartContainer'); + const severityGroups = { critical: ['critical_high','critical','critical_low','emergency'], warning: ['warning_high','warning','warning_low','error'], info: ['notice','info','debug'] }; const severityCounts = { critical: 0, warning: 0, info: 0 }; - counts.forEach(c => { if (c.status !== 'resolved' && severityCounts[c.severity] !== undefined) severityCounts[c.severity] += parseInt(c.count); }); + counts.forEach(c => { + if (c.status === 'resolved') return; + for (const [group, levels] of Object.entries(severityGroups)) { + if (levels.includes(c.severity)) { + severityCounts[group] += parseInt(c.count); + break; + } + } + }); const maxVal = Math.max(...Object.values(severityCounts), 1); chartEl.innerHTML = `
${Object.entries(severityCounts).map(([sev, cnt]) => { const color = { critical: 'danger', warning: 'warning', info: 'info' }[sev] || 'secondary'; diff --git a/src/Model/AlertSeverity.php b/src/Model/AlertSeverity.php index 3448523..12073d1 100644 --- a/src/Model/AlertSeverity.php +++ b/src/Model/AlertSeverity.php @@ -4,7 +4,15 @@ namespace Jakach\Logging\Model; enum AlertSeverity: string { + case Debug = 'debug'; case Info = 'info'; + case Notice = 'notice'; + case WarningLow = 'warning_low'; case Warning = 'warning'; + case WarningHigh = 'warning_high'; + case Error = 'error'; + case CriticalLow = 'critical_low'; case Critical = 'critical'; + case CriticalHigh = 'critical_high'; + case Emergency = 'emergency'; } \ No newline at end of file