LoginSignup
7
8

More than 5 years have passed since last update.

Sensuの監視から、電話の一斉通知と対応履歴を管理する

Last updated at Posted at 2015-06-08

サーバ、システム保守する上で監視は要です。ただし監視すること自体は本質ではなく、障害が発生した時に、いかに早く気づきスムーズに対応できるかが重要です。

Sensuからメールだけじゃなく、自社の障害対応管理ツール「Reactio」というサービスを利用して電話での一斉通知とチャットでの対応する方法を共有します。

概要

  • Senseの設定
    • 初期設定
    • handlersの登録
  • Reactioの設定
    • プロジェクトのAPIキーの登録
    • インシデント作成プログラムの作成
  • まとめ

Sensuの設定

Sensuとは? (https://sensuapp.org/)
Ruby製の監視ソフトウェア。AWSなどのクラウド環境に強く、APIを利用した外部連携が得意。

Screen Shot 2015-06-08 at 11.52.18 AM.png

初期設定

初期設定と各種リファレンスはこちらの記事を参考に(割愛)
http://qiita.com/spesnova/items/f9a8c9661861cc453ead

hadlersの登録

参考)https://sensuapp.org/docs/latest/getting-started-with-handlers

  • Sensuに登録した監視リソースに下記を登録
/etc/sensu/conf.d/reactio_handler.json
{
  "reactio": {
    "api_key": "<APIキー>",
    "organization": "demo"
  },
  "handlers": {
    "reactio": {
      "type": "pipe",
      "command": "/etc/sensu/handlers/reactio_handler.rb",
      "serverities": ["critical"]
    }
  }
}

Reactioの設定

Reactioとは? (https://reactio.jp)
監視システムで検知した障害対応を、迅速に行い対応がそのまま記録され管理できるツール。

Screen Shot 2015-06-08 at 11.50.58 AM.png

プロジェクトのAPIキーの登録

本家のブログを参考(割愛)
http://blog.reactio.jp/entry/2015/05/26/161408

インシデント作成プログラムの作成

reactioのRuby版APIクライアントを利用してプログラムを作る
参考)http://blog.reactio.jp/entry/2015/05/13/172036

reactio_handler.rb
#!/usr/bin/env ruby
#
# Sensu Reactio Handler
# ===

require 'rubygems' if RUBY_VERSION < '1.9.0'
require 'sensu-handler'
require 'reactio'
require 'timeout'
require 'json'

class ReactioHandler < Sensu::Handler

  def event_name
    "#{@event['client']['name']}/#{@event['check']['name']}"
  end

  def handle
    return unless @event['action'].eql?('create')
    return unless @event['check']['status'].eql?(2)
    begin
      timeout(10) do
        create_reactio_incident
        puts "reactio -- incident #{event_name} created."
      end
    rescue Timeout::Error
      puts "reactio -- timed out while attempting to #{@event['action']} a incident -- #{event_name}"
    end
  end

  private

    def create_reactio_incident
      reactio.create_incident(
        "#{event_name} #{@event['check']['output']}",
        detection: 'internal',
        notification_text: '対応をお願いします',
        notification_call: false
      )
    end

    def reactio
      Reactio::Service.new(
        api_key: settings['reactio']['api_key'],
        organization: settings['reactio']['organization']
      )
    end
end

以上でセットアップ完了です。

まとめ

実際に障害が起きた時の流れ

  1. 監視対象サーバに問題が発生
  2. Sensuにて監視対象サーバの状態を検知して、アラート発報
    1. メールにてアラートを受信
    2. ReactioのAPIで自動でインシデント作成
  3. Reactioでインシデント登録
    1. 一斉通知機能で、プロジェクト関係者に電話通知(音声読み上げ)
  4. Reactioのグループチャットに集結して障害対応
  5. 通知先、通知内容、チャットの会話すべてが記録される
7
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
8