Back to Blog
Laravel Pulse: Real-Time Application Monitoring
Real-Time Insights
Laravel Pulse provides a beautiful, real-time dashboard for monitoring your application's health and performance. Unlike traditional APM tools, Pulse is built specifically for Laravel and understands its conventions.
Installation
composer require laravel/pulse
php artisan vendor:publish --provider="Laravel\Pulse\PulseServiceProvider"
php artisan migrate
What Pulse Monitors
- Slow requests and queries
- Application usage patterns
- Queue throughput and failures
- Cache hit/miss rates
- Exception frequency
- Server resource usage
Accessing the Dashboard
// In routes/web.php
Route::middleware(['auth', 'can:viewPulse'])->prefix('pulse')->group(function () {
Route::get('/', function () {
return view('pulse::dashboard');
});
});
// Authorization
Gate::define('viewPulse', function (User $user) {
return $user->isAdmin();
});
Custom Cards
class TopProductsCard extends Card
{
public function render(): View
{
$products = DB::table('order_items')
->select('product_id', DB::raw('SUM(quantity) as total'))
->groupBy('product_id')
->orderByDesc('total')
->limit(10)
->get();
return view('pulse.cards.top-products', [
'products' => $products,
]);
}
}
Sampling Configuration
// config/pulse.php
'sample_rate' => env('PULSE_SAMPLE_RATE', 1), // 1 = 100%
// Reduce storage for high-traffic apps
'storage' => [
'trim' => [
'lottery' => [1, 1000], // 1 in 1000 requests triggers trim
'keep' => '7 days',
],
],
Performance Considerations
Pulse uses minimal resources but can be tuned for high-traffic applications:
- Adjust sample rate for less granular but lower-overhead monitoring
- Use Redis for better performance
- Configure data retention periods
Conclusion
Pulse brings first-party monitoring to Laravel with zero configuration. Install it on every Laravel application you build.
Related Articles
Need Help With Your Project?
I respond to all inquiries within 24 hours. Let's discuss how I can help build your production-ready system.
Get In Touch