Skip to content

πŸ›‘οΈ Advanced real-time monitoring, performance tracking, and multi-channel alerting system for Laravel applications. Track slow queries, memory usage, exceptions, and response times with instant notifications via Telegram, Slack, Discord & Email.

License

Notifications You must be signed in to change notification settings

PicoBaz/laravel-sentinel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ Laravel Sentinel

Advanced monitoring and alerting system for Laravel applications with real-time notifications across multiple channels.

License PHP Laravel

✨ Features

  • πŸ” 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

πŸ“¦ Installation

composer require picobaz/laravel-sentinel

Publish Configuration

php artisan sentinel:install

This will:

  • Publish configuration file to config/sentinel.php
  • Publish views to resources/views/vendor/sentinel
  • Run migrations

βš™οΈ Configuration

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,
        ],
    ],
];

Environment Variables

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.com

πŸš€ Usage

Automatic Monitoring

Sentinel automatically monitors your application once installed. All modules run in the background.

Manual Logging

use PicoBaz\Sentinel\Facades\Sentinel;

Sentinel::log('custom', [
    'action' => 'user_login',
    'user_id' => 123,
    'ip' => request()->ip(),
]);

Middleware

Add to specific routes:

Route::middleware(['sentinel'])->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index']);
});

Dashboard

Access the dashboard at: http://your-app.test/sentinel

Artisan Commands

php artisan sentinel:status
php artisan sentinel:security-report --hours=24

πŸ” Security Monitoring (NEW in v1.1.0)

Features

The 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

Configuration

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.5

Middleware

Add security middleware to protect routes:

Route::middleware(['sentinel.security'])->group(function () {
    Route::get('/admin', [AdminController::class, 'index']);
});

Security Helper

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);

File Integrity Monitoring

use PicoBaz\Sentinel\Modules\SecurityMonitor\SecurityMonitorModule;

$monitor = app(SecurityMonitorModule::class);
$monitor->checkFileIntegrity([
    base_path('.env'),
    base_path('composer.json'),
]);

Security Report

Generate comprehensive security reports:

php artisan sentinel:security-report --hours=24

Output includes:

  • Failed login attempts
  • Suspicious requests by type
  • Rate limiting violations
  • Top threat IPs with security scores
  • Blacklisted IPs

🧩 Creating Custom Modules

namespace App\Sentinel\Modules;

class CustomModule
{
    public function boot()
    {
        // Your monitoring logic
    }
}

Register in config/sentinel.php:

'modules' => [
    'customModule' => true,
],

πŸ“± Notification Channels

Telegram

  1. Create a bot via @BotFather
  2. Get your chat ID from @userinfobot
  3. Configure in .env

Slack

  1. Create incoming webhook in Slack
  2. Add webhook URL to .env

Discord

  1. Create webhook in Discord server settings
  2. Add webhook URL to .env

πŸ“Š Metrics API

GET /sentinel/metrics/{type}?hours=24

Types: query, memory, exception, performance

Response:

[
    {
        "id": 1,
        "type": "query",
        "data": {...},
        "severity": "warning",
        "created_at": "2024-01-01 12:00:00"
    }
]

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“ License

This package is open-sourced software licensed under the MIT license.

πŸ‘€ Author

PicoBaz

🌟 Support

If you find this package helpful, please consider giving it a ⭐ on GitHub!

πŸ“š Documentation

For detailed documentation, visit https://github.com/PicoBaz/laravel-sentinel/wiki

πŸ› Issues

Report issues at https://github.com/PicoBaz/laravel-sentinel/issues

About

πŸ›‘οΈ Advanced real-time monitoring, performance tracking, and multi-channel alerting system for Laravel applications. Track slow queries, memory usage, exceptions, and response times with instant notifications via Telegram, Slack, Discord & Email.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published