The gem will let you report when something reaches a threshold, such as a job queue, and will intelligently alert whoever or whatever is configured to receive alerts.
Add this line to your application's Gemfile:
gem 'nifty_alert'
Or install it yourself as:
$ gem install nifty_alert
Set up recipients, maybe in a Rails initializer. Recipients can be Slack channels, with email support coming soon.
NiftyAlert.recipients = [
"https://mycompany.slack.com/services/hooks/slackbot?token=123abc4567def&channel=%23dev"
]
Report whatever you would like to monitor, such as the number of jobs in your queue, along with a threshold:
class EmailJob
def before(job)
nifty_alert = NiftyAlert.new(:job_queue)
nifty_alert.report(Delayed::Job.count, 1_000)
end
...
end
If the threshold has been reached, your Slack channel will be notified.
Don't worry, NiftyAlert will only alert you of an overage once every 15 minutes.
- Fork it ( https://github.com/[my-github-username]/nifty_alert/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request