How to Monitor Livewire with Vigilmon
Laravel Livewire lets you build reactive, dynamic interfaces without writing JavaScript — your components re-render server-side and sync to the DOM automatically. But when your Laravel server slows down or your session driver fails, Livewire components quietly stop updating. Users see stale data. Forms don't submit. No error, just a broken experience.
This tutorial shows you how to monitor a Livewire app so you know about problems before your users do.
Why Livewire monitoring is worth doing right
Livewire is different from traditional Laravel apps in one important way: every user interaction triggers a server round-trip. A standard contact form hit your backend once per submission. A Livewire search component hits your backend on every keypress.
This means the surface area for failures is wider:
- Laravel server down — all requests fail, obvious
- Session driver degraded — Livewire loses component state, components reset unexpectedly
- Queue worker stopped — deferred Livewire operations and listeners back up
- Database slow — response times spike, components appear to hang
Each of these needs a monitor.
Step 1: Add a health check endpoint
Laravel doesn't ship with a health check endpoint out of the box. Add one with the laravel-health package:
composer require spatie/laravel-health
Publish the configuration:
php artisan vendor:publish --tag="health-config"
Register the checks you need in AppServiceProvider:
// app/Providers/AppServiceProvider.php
use Spatie\Health\Checks\Checks\DatabaseCheck;
use Spatie\Health\Checks\Checks\CacheCheck;
use Spatie\Health\Checks\Checks\RedisCheck;
use Spatie\Health\Facades\Health;
public function boot(): void
{
Health::checks([
DatabaseCheck::new(),
CacheCheck::new(),
RedisCheck::new(),
]);
}
Register the health route:
// routes/web.php
use Spatie\Health\Http\Controllers\HealthCheckResultsController;
Route::get('/health', HealthCheckResultsController::class);
Test it:
curl http://localhost:8000/health
# {"finishedAt":"...","checkResults":[...]}
Step 2: Add a Livewire-specific health check
Livewire components use sessions and sometimes queues. Create a dedicated check:
// app/Http/Controllers/LivewireHealthController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class LivewireHealthController extends Controller
{
public function __invoke(): JsonResponse
{
$checks = [];
// Database
try {
DB::select('SELECT 1');
$checks['database'] = 'ok';
} catch (\Exception $e) {
$checks['database'] = 'error: ' . $e->getMessage();
}
// Cache / session driver
try {
$key = 'livewire_health_' . now()->timestamp;
Cache::put($key, 'ok', 10);
$val = Cache::get($key);
Cache::forget($key);
$checks['cache'] = $val === 'ok' ? 'ok' : 'mismatch';
} catch (\Exception $e) {
$checks['cache'] = 'error: ' . $e->getMessage();
}
// Livewire class resolution
try {
$checks['livewire'] = class_exists(\Livewire\Livewire::class) ? 'ok' : 'not_found';
} catch (\Exception $e) {
$checks['livewire'] = 'error';
}
$status = in_array('ok', array_values($checks)) &&
!in_array(true, array_map(fn($v) => str_starts_with((string)$v, 'error'), array_values($checks)));
return response()->json([
'status' => $status ? 'ok' : 'degraded',
'checks' => $checks,
], $status ? 200 : 503);
}
}
Register the route:
// routes/web.php
Route::get('/health/livewire', \App\Http\Controllers\LivewireHealthController::class);
Test:
curl http://localhost:8000/health/livewire
# {"status":"ok","checks":{"database":"ok","cache":"ok","livewire":"ok"}}
Step 3: Set up Vigilmon monitoring
Add both endpoints to Vigilmon:
- Sign up at vigilmon.online
- Click New Monitor → HTTP
Monitor 1 — Laravel server health:
- URL:
https://yourdomain.com/health - Interval: every 1 minute
- Expected status: 200
Monitor 2 — Livewire stack health:
- URL:
https://yourdomain.com/health/livewire - Interval: every 1 minute
- Expected status: 200
- Expected body contains:
"status":"ok"
Step 4: Add Slack alerts
- Go to Settings → Integrations → Slack in Vigilmon
- Click Connect Slack and pick your channel
- Enable Alert on failure on each monitor
You'll get notified within seconds of a failure — no more finding out from support tickets.
Step 5: Key metrics to track
| Metric | Warning | Critical | |--------|---------|----------| | HTTP response time | > 300ms | > 1000ms | | Livewire health response time | > 300ms | > 1000ms | | 7-day uptime | < 99.9% | < 99% | | Consecutive failures before alert | 1 | 1 |
Livewire makes many more HTTP requests per user than a traditional Laravel app. Response time under 300ms is essential for a smooth component interaction experience — use this threshold to catch database or cache slowness early.
Step 6: Monitoring queue workers (optional)
If you use Livewire's event broadcasting or deferred operations, you likely run queue workers. Set up a cron-based heartbeat:
// app/Console/Kernel.php
$schedule->call(function () {
// Write a heartbeat to cache; Vigilmon polls it
Cache::put('queue_worker_heartbeat', now()->toIso8601String(), 300);
})->everyMinute();
Then add a heartbeat endpoint:
Route::get('/health/queue', function () {
$heartbeat = Cache::get('queue_worker_heartbeat');
$lastBeat = $heartbeat ? \Carbon\Carbon::parse($heartbeat) : null;
$ok = $lastBeat && $lastBeat->diffInMinutes(now()) < 5;
return response()->json([
'status' => $ok ? 'ok' : 'stale',
'last_heartbeat' => $heartbeat,
], $ok ? 200 : 503);
});
Add this as a third Vigilmon monitor.
Step 7: Public status page
Create a status page for transparent incident communication:
- In Vigilmon, go to Status Pages → New Status Page
- Add all monitors
- Set a custom domain (e.g.
status.yourdomain.com) - Publish
Conclusion
Livewire's server-driven reactivity means your monitoring strategy needs to cover more than just HTTP uptime. With Vigilmon you get:
- Laravel server health monitoring
- Cache, session, and Livewire component layer monitoring
- Optional queue worker heartbeat monitoring
- Instant Slack alerts on any failure
- Public status page for incidents
Sign up at vigilmon.online and have production-grade Livewire monitoring running in under 30 minutes.