PAGER DUTY & EXCEPTION NOTIFIER PLUGINS FOR RAILS

PagerDuty gives you an overall view of all your monitoring alarms and alerts in one place. Let’s have a look at the key attributes of this expedient plug-in:

Serves as a Monitoring aggregation tool

PagerDuty serves as an alarm aggregation and dispatching tool for the system administration and support teams. While collecting the alerts from your monitoring tools, it imparts an overall view of all your monitoring alarms, and alerts to your on-duty engineers, keeping them updated in the real-time in case there’s a problem. It is compatible to work with a wide variety of monitoring systems which include all open-source and commercial tools. Some of the noteworthy monitoring tools include ServerDensity, CloudKick, Monit, New Relic, Rails Exception Notifier etc. So, you can use any monitoring tools to connect with Pagerduty and this lets you view the errors from all of your monitoring systems under the services.

It is easy to set up!

Integrating PagerDuty with your existing monitoring tools is a breeze. Each PagerDuty service you create has an associated email address. All you need to do is to just configure your monitoring systems to send email to one of your PagerDuty services in case a problem gets detected. By using the Events API (v2) you can add the advanced functionality of PagerDuty’s event and incident management to practically any monitoring system that is capable of making an
HTTP API call.

It wakes you up when stuff breaks

PagerDuty provides an effective alerting via Phone, SMS and Email when something breaks in the server. PagerDuty doesn’t limit us to use only one alerting media and it can even be configured to retry alerts if the call or SMS goes unanswered.

Accepts commands from your mobile phone

PagerDuty doesn’t just alert you of the problems using SMS and phone calls — it also lets you take action directly from your mobile phone. So, the person on-call has the option to acknowledge, escalate or resolve a triggered incident by replying to the alert SMS, or simply, by pressing a key during a phone alert.
So, in all, three actions can be taken in such an incident: acknowledge, escalate, or resolve. Thus, a triggered incident can be acknowledged and acknowledging an incident is like hitting the snooze button on an alarm clock — PagerDuty stops alerting the on-call person about the incident once acknowledged.
Just like snooze, the incident acknowledgement can be configured to time out and re-alert after a certain amount of time. The purpose of acknowledging an incident is to signal that you’ve received the alert and are now working to fix the problem. Once the alert is received the incident can be escalated to another person and be resolved.

Escalation policies

Each PagerDuty service has an associated escalation policy that specifies how the alerts should be routed to the team working on the same application. We can add multiple users along with specifying the degree of priority (primary-on-call or seconday-on-call) to receive the alert after a given amount of time.

On-call scheduling

With PagerDuty, the on-call responsibilities can be shared by creating on-call schedules. When an incident is triggered, PagerDuty can automatically routes the alerts to the person according to the predefined on-call schedule. PagerDuty lets you build different on-call schedules for each specialization within your organization. For example, you can create one schedule for your database administrators, and another for your network engineers. The Alerts in all the cases shall be trigger to the on call person.
Thus, PagerDuty helps us quickly build an on-call schedule by specifying an on-call rotation. You just need to predefine the people between whom the ‘on-call duty’ should rotate, how long you want each on-call shift to be, and when you want ‘on-call duty’ to get handed over among the team members.
In addition to this, you can also override a schedule. For example, suppose in case someone in the team is on leave, you can override a predefined schedule to make alternative arrangements so that someone else can be on-call in their place for that specific period.

Auto-escalation

Auto-excalation helps ensure that your alerts are always answered. PagerDuty protects you against accidentally overlooked incidents by letting us specify comprehensive escalation rules. When an incident is triggered, PagerDuty first tries to contact the level-one person. In case the call is not answered by that person on time, an auto-escalation of the alert happens to the level-two person, and so on. In this way, as many levels of escalation can be defined as needed and the escalation delay is user adjustable.

Alerts internationally

With PagerDuty, you can reach your team internationally with both phone calls and SMS alerts – Pagerduty is capable of sending alerts to over one hundred countries.

RAILS EXCEPTION NOTIFIER

The Exception Notifier plugin provides a mailer object and a default set of templates for sending email notifications when errors occur in a Rails application. It is basically a monitoring tool, which keeps on watching the application and whenever it finds any error, it triggers that error to PagerDuty. To use Exception Notification and PagerDuty in your app, you need to add this gem below:

gem 'exception_notification', '~> 4.1.0'
gem  'pagerduty''

To get the email notifications, you need to include the line below in the development env:

Rails.application.config.middleware.use ExceptionNotification::Rack,
                  :email => {
                   :email_prefix => "[PREFIX] ",
                   :sender_address => %{"notifier" },
                   :exception_recipients => %w{[email protected]},
                   :pd => {
                            # simple notifier options
                          }
                }

You can modify sender’s and recipient’s address.

Rails App+PagerDuty
Use the code below in your app with exception notifier to connect with PagerDuty:

require "pagerduty"
module ExceptionNotifier
       Class PdNotifier
           def initialize(options)
             @pagerduty = Pagerduty.new("0bdcfdacf1b144d7822dfdfa5ed0ab1e")# Service api key
            # do something with the options...
          end
         def call(exception, options={})
            @pagerduty.trigger(exception.message, details: { backtrace: exception.backtrace })
        end
    end
end

Conclusion

PagerDuty is alert dispatching tool used by operations team/OnCall Engineers to manage the applications and it is popular because of its reliable & rich services(Scheduling,Alerting,Reporting,Call Routing , Feedback & response time).

Create your Free account from https://app.pagerduty.com/ and integrate with your application to get the flow , how Incident is triggered.