itxrahulsingh / laravel-monitor
Real-time monitoring for Laravel applications
Requires
- php: ^8.1
- laravel/framework: ^10.0|^11.0
- livewire/livewire: ^3.0
This package is not auto-updated.
Last update: 2025-05-02 18:47:36 UTC
README
A real-time monitoring package for Laravel applications, with server metrics (CPU, memory, disk usage) and a Livewire-powered dashboard.
Installation
-
Install the package via Composer:
composer require itxrahulsingh/laravel-monitor
-
Publish the configuration file:
php artisan vendor:publish --tag=laravel-monitor-config
-
Publish the migrations:
php artisan vendor:publish --tag=laravel-monitor-migrations
-
Run the migrations to create the necessary database tables:
php artisan migrate
Configuration
Edit config/laravel-monitor.php
to customize monitoring settings, including:
- Recorders (e.g., requests, slow queries, exceptions, jobs, system metrics).
- Notification channels (e.g., email, Slack) and thresholds.
- Data retention periods.
- Dashboard settings (e.g., route, middleware, polling interval).
Example configuration:
return [ 'enabled' => env('MONITOR_ENABLED', true), 'recorders' => [ 'requests' => ['enabled' => true, 'sample_rate' => 0.1], 'slow_queries' => ['enabled' => true, 'threshold_ms' => 1000], 'system' => ['enabled' => true, 'metrics' => ['cpu_usage', 'memory_usage', 'disk_usage']], ], 'notifications' => [ 'channels' => [ 'email' => ['enabled' => true, 'to' => 'rahulsingh4041@gmail.com'], ], ], 'dashboard' => [ 'route' => '/monitor', 'middleware' => ['web', 'auth', 'can:view-monitor-dashboard'], ], ];
Usage
-
Access the dashboard at
/monitor
(ensure you're authenticated and authorized). -
View real-time metrics, logs, charts, and alerts.
-
Schedule the data trimming command to manage database size:
php artisan monitor:trim
Add to
app/Console/Kernel.php
for daily execution:$schedule->command('monitor:trim')->daily();
-
Schedule system metrics collection:
$schedule->call(function () { (new \Itxrahulsingh\LaravelMonitor\Recorders\SystemMetricsRecorder)->record(); })->everyMinute();
Features
- Real-Time Monitoring: Track HTTP requests, slow queries, exceptions, queue jobs, and server metrics (CPU, memory, disk).
- Pulse-Like Data Storage: Efficient database schema with values, entries, and aggregates.
- Livewire Dashboard: Displays cards, charts, logs, and alerts with real-time updates.
- Notifications: Configurable alerts via email, Slack, etc., for critical events.
- Data Retention: Automatic trimming of old data.
- Extensibility: Add custom recorders and dashboard widgets.
Testing
Run the included tests to verify functionality:
php artisan test
Contributing
Contributions are welcome! Please:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/your-feature
). - Commit your changes (
git commit -m 'Add your feature'
). - Push to the branch (
git push origin feature/your-feature
). - Open a pull request on GitHub.
Issues
Report bugs or request features by opening an issue on GitHub.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
License
MIT License
Copyright (c) 2025 Rahul Singh
See the LICENSE file for details.
Contact
For support, contact Rahul Singh at rahulsingh4041@gmail.com.