Package Data | |
---|---|
Maintainer Username: | saasscaleup |
Maintainer Contact: | saasscaleup@gmail.com (Scale-Up SaaS) |
Package Create Date: | 2024-06-20 |
Package Last Update: | 2025-01-22 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-05 15:00:02 |
Package Statistics | |
---|---|
Total Downloads: | 4,756 |
Monthly Downloads: | 1,451 |
Daily Downloads: | 71 |
Total Stars: | 231 |
Total Watchers: | 3 |
Total Forks: | 13 |
Total Open Issues: | 3 |
Log Alarm is a robust and easy-to-use Laravel package designed to enhance your application's logging capabilities. Whether you're running a small web app or a large enterprise system, Log Alarm helps you stay on top of your logs by providing real-time monitoring, error detection, and instant notifications via Slack and email.
In today's fast-paced digital environment, timely responses to application issues are crucial. Log Alarm ensures that you and your team are promptly informed about critical errors, reducing downtime and improving your application's reliability. Perfect for developers, system administrators, and DevOps teams looking to enhance their monitoring capabilities.
Install the package via Composer:
composer require saasscaleup/laravel-log-alarm
Add Service Provider to config/app.php
in providers
section
Saasscaleup\LogAlarm\LogAlarmServiceProvider::class,
Publish package's config, migration and view files by running below command:
php artisan vendor:publish --provider="Saasscaleup\LogAlarm\LogAlarmServiceProvider"
The package will automatically start listening to your application's log events. Customize the settings in the config/log-alarm.php
file to match your requirements.
For Example:
LA_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/your/webhook/url
LA_NOTIFICATION_EMAIL=your-email@example.com
LA_NOTIFICATION_EMAIL_SUBJECT="Log Alarm Notification"
In order to trigger the Log Alarm with the current defualt setting, All you need to do is
LA_SLACK_WEBHOOK_URL
and LA_NOTIFICATION_EMAIL
tinker
or in your Controller
Add LA_TELEGRAM_BOT_TOKEN
and LA_TELEGRAM_CHAT_ID
to your .env
@BotFather
/newbot
MyTelegramBot
or my_telegram_bot
123456789:ABCdefGHIjklMNOpqrsTUVwxyz
https://api.telegram.org/bot<YourBotTokenHere>/getUpdates
123456789
."chat": {
"id": 123456789,
},
Keep your bot token secret - anyone with it can control your bot For groups, make sure to give the bot permission to read messages If you don't see any updates in the /getUpdates response, send a new message to the bot or group The chat ID is permanent for that chat or group unless the bot is removed and re-added
php artisan tinker
\Log::error('Log alarm');
\Log::error('Log alarm');
\Log::error('Log alarm');
\Log::error('Log alarm');
\Log::error('Log alarm');
After the fifth error log message, email and slack notification will be sent! (Email example)
From: Laravel <hello@example.com>
To: admin@example.com, admin2@example.com
Subject: Log Alarm Notification
The Error was occurred 5 times in the last 1 minutes:
LOG_LEVEL: error | LOG_MESSAGE: Log alarm
Update your .env
file with the following environment variables:
LA_ENABLED=true
LA_LOG_TYPE=error
LA_LOG_TIME_FRAME=1
LA_LOG_PER_TIME_FRAME=5
LA_DELAY_BETWEEN_ALARMS=5
LA_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/your/webhook/url
LA_NOTIFICATION_EMAIL=your-email@example.com
LA_NOTIFICATION_EMAIL_SUBJECT="Log Alarm Notification"
Here's the full configuration file content for config/log-alarm.php
:
<?php
return [
// enable or disable LOG ALARM
'enabled' => env('LA_ENABLED', true),
// log listener for specific log type
'log_type' => env('LA_LOG_TYPE', 'error'), // also possible: 'error,warning,debug'
// log time frame - log time frame to listen - in minutes
"log_time_frame" => (int)env('LA_LOG_TIME_FRAME', 1),
// log per time frame - How many log to count per time frame until alarm trigger
"log_per_time_frame" => (int)env('LA_LOG_PER_TIME_FRAME', 5),
// delay between alarms in minutes - How many minutes to delay between alarms
'delay_between_alarms' => (int)env('LA_DELAY_BETWEEN_ALARMS', 5),
// log listener for specific word inside log messages
'specific_string' => env('LA_SPECIFIC_STRING', ''), // also possible: 'table lock' or 'foo' or 'bar' or leave empty '' to enable any word
// notification message for log alarm
'notification_message' => env('LA_NOTIFICATION_MESSAGE', 'Log Alarm got triggered!'),
// Slack webhook url for log alarm
'slack_webhook_url' => env('LA_SLACK_WEBHOOK_URL', ''),
// notification email address for log alarm
'notification_email' => env('LA_NOTIFICATION_EMAIL', 'admin@example.com,admin2@example.com'),
// notification email subject for log alarm
'notification_email_subject' => env('LA_NOTIFICATION_EMAIL_SUBJECT', 'Log Alarm Notification'),
];
We welcome contributions! Please feel free to submit a Pull Request or open an Issue on GitHub.
This package is open-sourced software licensed under the MIT license.
If you Like the tutorial and you want to support my channel so I will keep releasing amzing content that will turn you to a desirable Developer with Amazing Cloud skills... I will realy appricite if you:
Thanks for your support :)
Enhance your Laravel application's monitoring capabilities today with Log Alarm. Get started by installing the package and experience improved error management and faster response times.