Giter VIP home page Giter VIP logo

onduty's Introduction

OnDuty

OnDuty

Manage OnDuty contacts and trigger alarms via phone, SMS, Slack and Email.

Setup

Depedencies

  • Runtime: Ruby 2.2+ required
  • Database: MongoDB
  • Alert Acknowledgement: Icinga2
  • Phone and SMS alerts: Twilio

Dependencies are managed using bundler (install the bundler gem if you don't have it).

bundle install

Base configuration

# Application environment, i.e. production, test, development
APP_ENV=development
# MongoDB connection URI
MONGODB_URI=mongodb://mongodbserver:27017/onduty
# Application base URL
ONDUTY_BASE_URL=http://localhost:3000/
# How many alerts are required to trigger a notification
ONDUTY_ALERT_LIMIT=2
# When to consider an existing alert as new (in seconds)
# when the time is below this value the count of an alert goes up
ONDUTY_ALERT_THRESHOLD=7200

# Optionally set some constraints to the phone numbers of the Onduty Contacts,
# with comma separated (wihout spaces) code countries and phone types
# (see https://github.com/daddyz/phonelib#getting-started for more details)
# ONDUTY_PHONE_COUNTRIES=ch
# ONDUTY_PHONE_TYPES=fixed_line,mobile

Build & Run with Docker

Build the image:

docker build -t onduty:latest .

Run it together with mongodb:

docker-compose up

Access Control

OnDuty protects access using basic auth, when you set the ENV variables ONDUTY_ADMIN_USER and ONDUTY_ADMIN_PASSWORD:

ONDUTY_ADMIN_USER=admin
ONDUTY_ADMIN_PASSWORD=password

The alert acknowledge and twiml methods are protected by alert UID.

Icinga2 acknowledge

Configure the Icinga2 API:

ONDUTY_ICINGA2_API_PATH=https://icinga2.local:5665/v1
ONDUTY_ICINGA2_WEB_PATH=http://icinga2.local
ONDUTY_ICINGA2_USER=icinga2-onduty
ONDUTY_ICINGA2_PASSWORD=icinga2-password

Run the server

OnDuty is a Sinatra Webapp and can be started using any Rack compatible webserver.

From the application base directory:

rackup config.ru

...or run it directly with Puma:

puma config.ru -p 80

JSON API

You can get JSON output for several resources.

Example for getting the primary onduty contact for group "Infrastructure":

GET /contacts.json?duty=primary&group_name=Infrastructure

Getting all groups:

GET /groups.json

CLI

See bundle exec bin/onduty-cli for a cli help.

Plugins

The following plugins are available:

  • VoiceNotification (using Twilio)
  • SmsNotification (using Twilio)
  • MailNotification
  • SlackNotification
  • ZendeskNotification

Plugins can be enabled/disabled using ENV.

This is the default configuration:

ONDUTY_NOTIFICATION_PLUGINS=VoiceNotification,MailNotification

Check the plugins state using the onduty-cli:

bundle exec bin/onduty-cli plugins

Plugin Configuration Parameters

Twilio VoiceNotification and SmsNotification

In order to use the VoiceNotification and SmsNotification plugins you have to configure the following twilio account parameters:

ONDUTY_TWILIO_ACCOUNT_SID=<account-sid>
ONDUTY_TWILIO_ACCOUNT_TOKEN=<account-token>
ONDUTY_TWILIO_FROM_NUMBER=+411235678

MailNotification

[email protected]
ONDUTY_SMTP_ADDRESS=smtprelay.onduty.local

SlackNotification

  1. Add a new bot on your Slack account and take note of the API token.
  2. Invite your new bot to the channel your are going to configure within OnDuty.
ONDUTY_SLACK_API_TOKEN=<slack-api-token>
ONDUTY_SLACK_CHANNEL=#onduty-test

ZendeskNotification

ONDUTY_ZENDESK_URL=https://<your-workspace>.zendesk.com/api/v2
[email protected]
ONDUTY_ZENDESK_TOKEN=<zendesk-token>
# ONDUTY_ZENDESK_GROUP_ID=<zendesk-group-id>
# ONDUTY_ZENDESK_SKIPPED_GROUPS=RedTeam,BlueTeam

When ONDUTY_ZENDESK_GROUP_ID is not defined, the assignee's default group id will be used.

When ONDUTY_ZENDESK_SKIPPED_GROUPS is defined (with existing group names as comma-separated list), no Zendesk tickets will be created for alerts of these groups.

Trigger alerts from external sources

The following example shows how to create an alert using cURL and JSON payload:

curl -v -i -X POST -H "Content-Type: application/json" \
--data '{"alert":{"name":"test_alert","group":"Test","services":[{"name":"service1","host":"host1"},{"name":"service2","host":"host2"}]},"force":"false"}' \ 'http://admin:[email protected]:3000/alerts/new.json'

onduty's People

Contributors

dependabot[bot] avatar gildegoma avatar niwo avatar srgoni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

onduty's Issues

Program Error in the Email Notification Plugin

Error message:

Onduty::Notification: Error sending email: undefined method `email' for nil:NilClass

Note: not urgent since this plugin will be disabled (superseeded by Zendesk Ticket creation, which also generate an e-mail notification)

Improve Alert Notification trigger rule

In order to not trigger Alert notifications "too early", Onduty should not only rely on the alert counter, but also ensure that at least one of the related Icinga service check(s) have reached an hard state (critical during 3 minutes in a row).

In the example below, no notifications should be sent (even if the alert counter crossed the ONDUTY_ALERT_LIMIT).

image

Attention: (to be studied) there is a potential risk to not report continuously flapping service (having two alert limits could be a solution: hard state limit e.g. >1, soft state limit, e.g. >5).

Improve host/service visiblity inside Icinga2

Currently, when acknowledging the Onduty alarm, you are also acknowledging the host/service. Then searching of the according check inside Icinga is needed.
I would like a behavior where the service wouldn't be acknowledged by Icinga and it would be on top of Icinga 2.

Maybe this is possible to integrate by writing a temporary comment in Icinga2 or with the Dashboard always showing the acknowledged Onduty alarms on top.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.