All Projects → kevincobain2000 → laravel-alert-notifications

kevincobain2000 / laravel-alert-notifications

Licence: MIT license
Send alert to email, microsoft teams from laravel app, when an exception occurs. Throttle is enabled by default.

Programming Languages

PHP
23972 projects - #3 most used programming language
Blade
752 projects

Projects that are alternatives of or similar to laravel-alert-notifications

sentry-msteams
Microsoft Teams Integration for Sentry
Stars: ✭ 27 (+22.73%)
Mutual labels:  alerts, microsoft-teams
stream-throttle
Rust Stream combinator, to limit the rate at which items are produced
Stars: ✭ 19 (-13.64%)
Mutual labels:  throttle
CodeConversations
Code Conversations was a Demo is Scott Hanselman's keynote at Microsoft BUILD 2020. Code Conversations was designed with one goal in mind - to see if we could bring the power of .NET Interactive into Microsoft Teams, to create a way for people to have collaborative conversations about small bits of code.
Stars: ✭ 109 (+395.45%)
Mutual labels:  microsoft-teams
anim-event
Event Manager for Animation
Stars: ✭ 25 (+13.64%)
Mutual labels:  throttle
add-tradingview-alerts-tool
Automated entry of TradingView alerts for bot trading tools such as 3Commas, Alertatron, CryptoHopper, etc.
Stars: ✭ 467 (+2022.73%)
Mutual labels:  alerts
PSBlackListChecker
Basic functionality of this module is ability to quickly verify if given IP address is on any of over 80 defined DNSBL lists. Below code will return results only if IP is on any of the lists. Advanced functionality of this module is ability to send reports to your email when things get bad on one of those 80 defined DNSBL listrs.
Stars: ✭ 50 (+127.27%)
Mutual labels:  microsoft-teams
MsftTeams
Module for Posting messages to MSTeams via Webhook
Stars: ✭ 35 (+59.09%)
Mutual labels:  microsoft-teams
send2teams
Small CLI tool used to submit messages to Microsoft Teams.
Stars: ✭ 18 (-18.18%)
Mutual labels:  microsoft-teams
Microsoft365
Manage Microsoft 365 with PowerShell
Stars: ✭ 30 (+36.36%)
Mutual labels:  microsoft-teams
together
Group things together!
Stars: ✭ 35 (+59.09%)
Mutual labels:  throttle
msbotbuilder-go
Microsoft Bot Framework SDK for Go
Stars: ✭ 113 (+413.64%)
Mutual labels:  microsoft-teams
aws-health-aware
AHA is an incident management & communication framework to provide real-time alert customers when there are active AWS event(s). For customers with AWS Organizations, customers can get aggregated active account level events of all the accounts in the Organization. Customers not using AWS Organizations still benefit alerting at the account level.
Stars: ✭ 214 (+872.73%)
Mutual labels:  alerts
trovilo
trovilo collects and prepares files from Kubernetes ConfigMaps for Prometheus & friends
Stars: ✭ 16 (-27.27%)
Mutual labels:  alerts
List-Formatting
List Formatting Samples for use in SharePoint and Microsoft Lists
Stars: ✭ 1,227 (+5477.27%)
Mutual labels:  microsoft-teams
QuickTeams
Download, Clone, Archive, Un-Archive your Microsoft Teams and manage the apps you've installed to them
Stars: ✭ 31 (+40.91%)
Mutual labels:  microsoft-teams
WPWatcher
Wordpress Watcher is a wrapper for WPScan that manages scans on multiple sites and reports by email and/or syslog. Schedule scans and get notified when vulnerabilities, outdated plugins and other risks are found.
Stars: ✭ 34 (+54.55%)
Mutual labels:  alerts
MyDemos
💾 Demo 集合 . 黑发不知勤学早,白首方悔读书迟.
Stars: ✭ 64 (+190.91%)
Mutual labels:  throttle
asyncio-throttle
Simple, easy-to-use throttler for asyncio.
Stars: ✭ 95 (+331.82%)
Mutual labels:  throttle
tradingview-webhooks
Backend service converting tradingview alerts into action.
Stars: ✭ 44 (+100%)
Mutual labels:  alerts
rush
rush.readthedocs.io/en/latest/
Stars: ✭ 42 (+90.91%)
Mutual labels:  throttle

Laravel Alert Notifications

All Contributors

Travis Build Status Quality Score Build Status Coverage Status

Send php exceptions to email, microsoft teams, slack. Notifications are throttle enabled so devs don't get a lot of emails from one host (or all hosts if cache driver is shared) Please check config for more details on throttling.

Channels Progress
Email Supported
Microsoft Teams Supported
Slack Supported
Pager Duty Open to pull requests

Installation

composer require kevincobain2000/laravel-alert-notifications

If you're using Laravel 5.5+ let the package auto discovery make this for you.

'providers' => [
    \Kevincobain2000\LaravelAlertNotifications\AlertNotificationsServiceProvider::class
]

Tests

composer install
composer run test

Publish (Laravel)

php artisan vendor:publish --provider="Kevincobain2000\LaravelAlertNotifications\AlertNotificationsServiceProvider"
php artisan config:cache

Publish (Lumen)

Since Lumen doesn't support auto-discovery, move config and view files to the destination directories manually

cp vendor/kevincobain2000/laravel-alert-notifications/src/config/laravel_alert_notifications.php config/laravel_alert_notifications.php
mkdir -p "resources/views/vendor/laravel_alert_notifications/" && cp vendor/kevincobain2000/laravel-alert-notifications/src/views/* resources/views/vendor/laravel_alert_notifications/

and add the following to bootstrap/app.php:

$app->register(Kevincobain2000\LaravelAlertNotifications\AlertNotificationsServiceProvider::class);

.env

ALERT_NOTIFICATION_MAIL_FROM_ADDRESS=
ALERT_NOTIFICATION_MAIL_TO_ADDRESS=
ALERT_NOTIFICATION_MAIL_NOTICE_TO_ADDRESS=
ALERT_NOTIFICATION_MAIL_WARNING_TO_ADDRESS=
ALERT_NOTIFICATION_MAIL_ERROR_TO_ADDRESS=
ALERT_NOTIFICATION_MAIL_CRITICAL_TO_ADDRESS=
ALERT_NOTIFICATION_MAIL_ALERT_TO_ADDRESS=
ALERT_NOTIFICATION_MAIL_EMERGENCY_TO_ADDRESS=
ALERT_NOTIFICATION_CACHE_DRIVER=file
ALERT_NOTIFICATION_MICROSOFT_TEAMS_WEBHOOK=
ALERT_NOTIFICATION_SLACK_WEBHOOK=
ALERT_NOTIFICATION_CURL_PROXY=

Usage

new AlertDispatcher( 
    Exception $e 
    [, array $dontAlertExceptions = []]         // Exceptions that shouldn't trigger notifications
    [, array $notificationLevelsMapping = []]   // [Exception class => Notification level] mapping
    [, array $exceptionContext = []]            // Array of context data
)

In app/Exceptions/Handler.php. It is better to use a try catch to prevent loop.

use Kevincobain2000\LaravelAlertNotifications\Dispatcher\AlertDispatcher;

class Handler extends ExceptionHandler
{
    private $exceptionLogLevels = [
        DebugLevelException::class => LogLevel::DEBUG,
        WarningLevelException::class => LogLevel::WARNING,
        ErrorLevelException::class => LogLevel::ERROR,
    ];

    protected $dontReport = [
        //
    ];

    public function report(Throwable $exception)
    {
        try {
            $dontReport = array_merge($this->dontReport, $this->internalDontReport);
            $alertDispatcher = new AlertDispatcher($exception, $dontReport, $this->exceptionLogLevels);
            $alertDispatcher->notify();
        } catch (Throwable $e) {
            // log any unexpected exceptions or do nothing
        }
        parent::report($exception);
    }
}

Config

config/env key purpose
throttle_enabled (default true) If false then library will send alerts without any throttling
throttle_duration_minutes (default 5 mins) If an exception has been notified
This will next notify after 5 mins when same exception occurs
cache_prefix This is a prefix for cache key. Your cache key will look like
laravel-alert-notifications-ExceptionClass-ExceptionCode
ALERT_NOTIFICATION_CURL_PROXY If your slack/MS teams require proxy, then set it up accordingly
default_notification_level Default notification level
exclude_notification_levels Do not send notification if it is of one of the listed level
mail E-mail config array:
mail.enabled (default true), false will not notify to email
mail.fromAddress (default null), null will not notify to email
mail.toAddress Default recipient e-mail address
mail.subject Default e-mail subject. May contain placeholders replaced afterwards with
correspondent exception data:
%ExceptionMessage% => $e->getMessage()
%ExceptionCode% => $e->getCode()
%ExceptionType% => $e->getType()
%ExceptionLevel% => current notification level
ex. 'subject' => 'Exception [%ExceptionType%] has ocurred'
mail.#level# Configs for each notification level
notification levels refer to those defined in \Psr\Log\LogLevel
mail.#level#.toAddress (default mail.to_address), #level# notification recipient e-mail
mail.#level#.subject #level# notification e-mail subject
microsoft_teams.enabled (default true), false will not notify to teams
microsoft_teams.webhook (default null), null will not notify to teams
slack.enabled (default true), false will not notify to slack
slack.webhook (default null), null will not notify to slack

Samples

Email

Email

Teams

Teams

Slack

Slack

References

  1. https://qiita.com/kidatti/items/8732114ec4d1727844b8
  2. https://laravel-news.com/email-on-error-exceptions

Contributors

Thanks goes to these wonderful people (emoji key):


Aaron Brigham

⚠️ 💻

Alexander Hupe

👀 ⚠️ 💻

Kit Loong

👀 ⚠️ 💻

Andrew Miller

👀 ⚠️ 💻

Pulkit Kathuria

👀 ⚠️ 💻

Masashi

⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].