Advanced monitoring and alerting system for Laravel applications with real-time notifications across multiple channels.
- π Query Monitoring - Detect and log slow database queries
- πΎ Memory Monitoring - Track memory usage and prevent leaks
- π¨ Exception Monitoring - Catch and categorize exceptions
- β‘ Performance Monitoring - Monitor response times
- π Security Monitoring - Track security threats and attacks (NEW v1.1.0)
- π Beautiful Dashboard - Real-time metrics visualization
- π Multi-Channel Alerts - Slack, Telegram, Discord, Email
- π§© Modular Architecture - Easily extend with custom modules
- βοΈ Smart Thresholds - Configurable alert triggers
- π Analytics - Detailed performance insights
composer require picobaz/laravel-sentinelphp artisan sentinel:installThis will:
- Publish configuration file to
config/sentinel.php - Publish views to
resources/views/vendor/sentinel - Run migrations
Edit config/sentinel.php:
return [
'enabled' => true,
'modules' => [
'queryMonitor' => true,
'memoryMonitor' => true,
'exceptionMonitor' => true,
'performanceMonitor' => true,
],
'thresholds' => [
'query_time' => 1000,
'memory_usage' => 128,
'response_time' => 2000,
],
'notifications' => [
'channels' => [
'telegram' => true,
'slack' => false,
'email' => true,
'discord' => false,
],
],
];SENTINEL_ENABLED=true
SENTINEL_QUERY_TIME_THRESHOLD=1000
SENTINEL_MEMORY_THRESHOLD=128
SENTINEL_RESPONSE_TIME_THRESHOLD=2000
SENTINEL_TELEGRAM_ENABLED=true
SENTINEL_TELEGRAM_BOT_TOKEN=your_bot_token
SENTINEL_TELEGRAM_CHAT_ID=your_chat_id
SENTINEL_SLACK_ENABLED=false
SENTINEL_SLACK_WEBHOOK=your_webhook_url
SENTINEL_EMAIL_ENABLED=true
SENTINEL_EMAIL_RECIPIENTS=admin@example.com,dev@example.comSentinel automatically monitors your application once installed. All modules run in the background.
use PicoBaz\Sentinel\Facades\Sentinel;
Sentinel::log('custom', [
'action' => 'user_login',
'user_id' => 123,
'ip' => request()->ip(),
]);Add to specific routes:
Route::middleware(['sentinel'])->group(function () {
Route::get('/dashboard', [DashboardController::class, 'index']);
});Access the dashboard at: http://your-app.test/sentinel
php artisan sentinel:status
php artisan sentinel:security-report --hours=24The Security Monitor module tracks and prevents security threats:
- β Failed login attempts
- β SQL Injection attempts
- β XSS (Cross-Site Scripting) attempts
- β Path traversal attempts
- β Command injection attempts
- β Rate limiting violations
- β Unauthorized access attempts
- β File integrity monitoring
- β IP blacklisting (manual & automatic)
- β Security scoring system
SENTINEL_SECURITY_MONITOR=true
SENTINEL_SECURITY_AUTO_BLOCK=true
SENTINEL_SECURITY_AUTO_BLOCK_SCORE=20
SENTINEL_SECURITY_BLACKLIST=192.168.1.100,10.0.0.5Add security middleware to protect routes:
Route::middleware(['sentinel.security'])->group(function () {
Route::get('/admin', [AdminController::class, 'index']);
});use PicoBaz\Sentinel\Modules\SecurityMonitor\SecurityHelper;
SecurityHelper::getSecurityScore('192.168.1.1');
SecurityHelper::addToBlacklist('192.168.1.100', 'Multiple failed logins');
SecurityHelper::removeFromBlacklist('192.168.1.100');
SecurityHelper::isIpBlacklisted('192.168.1.100');
SecurityHelper::getThreatLevel(45);use PicoBaz\Sentinel\Modules\SecurityMonitor\SecurityMonitorModule;
$monitor = app(SecurityMonitorModule::class);
$monitor->checkFileIntegrity([
base_path('.env'),
base_path('composer.json'),
]);Generate comprehensive security reports:
php artisan sentinel:security-report --hours=24Output includes:
- Failed login attempts
- Suspicious requests by type
- Rate limiting violations
- Top threat IPs with security scores
- Blacklisted IPs
namespace App\Sentinel\Modules;
class CustomModule
{
public function boot()
{
// Your monitoring logic
}
}Register in config/sentinel.php:
'modules' => [
'customModule' => true,
],- Create a bot via @BotFather
- Get your chat ID from @userinfobot
- Configure in
.env
- Create incoming webhook in Slack
- Add webhook URL to
.env
- Create webhook in Discord server settings
- Add webhook URL to
.env
GET /sentinel/metrics/{type}?hours=24Types: query, memory, exception, performance
Response:
[
{
"id": 1,
"type": "query",
"data": {...},
"severity": "warning",
"created_at": "2024-01-01 12:00:00"
}
]Contributions are welcome! Please feel free to submit a Pull Request.
This package is open-sourced software licensed under the MIT license.
PicoBaz
- Email: picobaz3@gmail.com
- GitHub: @PicoBaz
- Telegram: @picobaz
If you find this package helpful, please consider giving it a β on GitHub!
For detailed documentation, visit https://github.com/PicoBaz/laravel-sentinel/wiki
Report issues at https://github.com/PicoBaz/laravel-sentinel/issues