monitoring: Betriebsüberwachung Phase 1 — GlitchTip (Server- und Browserfehler), Fehlersignale ohne Exception, /health mit Scheduler-Herzschlag, ntfy-Alarme, fehlgeschlagene Anmeldungen im Verlauf, Umami im Kundenbereich, Versionsnummer
- GlitchTip über die Sentry-SDKs; Datenschutzfilter (nur User-ID, keine
Request-Bodys, Tokens aus URL/Query/Referer, E-Mails aus Meldungen).
Browser-SDK erst beim ersten Fehler nachgeladen.
- ReportErrorSignals: tote interne Links (404 mit eigenem Referrer), 403/429
für Angemeldete, 419 als gedrosselte Warnung.
- /health (Bearer-Token): DB, Cache, Queue-Rückstau, Scheduler-Herzschlag,
Plattenplatz → 200/503; Scheduler und Plattenplatz auch im Systemstatus.
- OperationalAlert zusätzlich per ntfy (JSON-POST), unabhängig von der Mail.
- Verlauf: login_failed (Grund unbekannt/kein Passwort/falsch),
login_lockout, two_factor_failed; IP nur als gekürzter HMAC.
- Umami: Kundenbereich mit eigenem Schalter und identify('user-<id>'),
nie im Admin/bei Impersonation; Query-Filter auch auf den Webseiten
(signierte Links gingen bisher an Umami).
- queue:prune-failed nach 30 Tagen.
- Versionsnummer: config('app.version') aus APP_VERSION oder Datei RELEASE
(git describe --tags), in GlitchTip, /health, Systemstatus, artisan about.
Plan: dev/betrieb/monitoring-plan.md (Entscheidungen M1–M9).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f2ed268b51
commit
8769a71100
42 changed files with 1896 additions and 9 deletions
|
|
@ -3,7 +3,9 @@
|
|||
use App\Mail\OperationalAlertMail;
|
||||
use App\Support\OperationalAlert;
|
||||
use Illuminate\Contracts\Queue\Job;
|
||||
use Illuminate\Http\Client\Request;
|
||||
use Illuminate\Queue\Events\JobFailed;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
|
@ -74,3 +76,57 @@ test('a failing queue job triggers an operational alert via the registered liste
|
|||
return str_contains($mail->summary, 'ClassifyPressRelease');
|
||||
});
|
||||
});
|
||||
|
||||
test('an alert is also pushed to ntfy as json with token and priority', function () {
|
||||
config()->set('monitoring.alerts.enabled', true);
|
||||
config()->set('monitoring.alerts.mail_to', null);
|
||||
config()->set('monitoring.alerts.ntfy', [
|
||||
'url' => 'https://ntfy.example.com/',
|
||||
'topic' => 'pressekonto-ops',
|
||||
'token' => 'tk_geheim',
|
||||
'priority' => 4,
|
||||
]);
|
||||
Http::fake(['ntfy.example.com/*' => Http::response(['id' => 'abc'])]);
|
||||
|
||||
OperationalAlert::send('Geplanter Task fehlgeschlagen: archive:purge', ['exit_code' => 1, 'queue' => ['a' => 'b']]);
|
||||
|
||||
Http::assertSent(function (Request $request) {
|
||||
return $request->url() === 'https://ntfy.example.com'
|
||||
&& $request->hasHeader('Authorization', 'Bearer tk_geheim')
|
||||
&& $request['topic'] === 'pressekonto-ops'
|
||||
&& $request['priority'] === 4
|
||||
&& str_contains($request['message'], 'archive:purge')
|
||||
&& str_contains($request['message'], 'exit_code: 1')
|
||||
&& str_contains($request['message'], 'queue: {"a":"b"}');
|
||||
});
|
||||
});
|
||||
|
||||
test('a failing ntfy push neither bubbles up nor stops the mail', function () {
|
||||
config()->set('monitoring.alerts.enabled', true);
|
||||
config()->set('monitoring.alerts.mail_to', 'ops@example.com');
|
||||
config()->set('monitoring.alerts.ntfy.url', 'https://ntfy.example.com');
|
||||
config()->set('monitoring.alerts.ntfy.topic', 'pressekonto-ops');
|
||||
Mail::fake();
|
||||
Http::fake(['ntfy.example.com/*' => Http::response('down', 502)]);
|
||||
|
||||
OperationalAlert::send('Etwas ist kaputt');
|
||||
|
||||
Mail::assertSent(OperationalAlertMail::class);
|
||||
Http::assertSentCount(1);
|
||||
});
|
||||
|
||||
test('no push is sent when alerts are disabled or ntfy is not configured', function () {
|
||||
Http::fake();
|
||||
config()->set('monitoring.alerts.ntfy.url', 'https://ntfy.example.com');
|
||||
config()->set('monitoring.alerts.ntfy.topic', null);
|
||||
config()->set('monitoring.alerts.enabled', true);
|
||||
|
||||
OperationalAlert::send('Etwas ist kaputt');
|
||||
|
||||
config()->set('monitoring.alerts.ntfy.topic', 'pressekonto-ops');
|
||||
config()->set('monitoring.alerts.enabled', false);
|
||||
|
||||
OperationalAlert::send('Etwas ist kaputt');
|
||||
|
||||
Http::assertNothingSent();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue