Coder Social home page Coder Social logo

aspectcapital / sensu-plugins-opsgenie Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sensu-plugins/sensu-plugins-opsgenie

0.0 1.0 0.0 90 KB

Sensu plugins for OpsGenie

Home Page: http://sensu-plugins.io

License: MIT License

Ruby 100.00%

sensu-plugins-opsgenie's Introduction

Sensu-Plugins-opsgenie

Build Status Gem Version Code Climate Test Coverage Dependency Status

Functionality

Files

  • bin/handler-opsgenie.rb
  • bin/check-opsgenie-heartbeat.rb

Usage

handler-opsgenie

{
  "opsgenie": {
    "customerKey": "the-key",
    "teams": [
      { "name": "the-team" },
      { "id": "4513b7ea-3b91-438f-b7e4-e3e54af9147c" }
    ],
    "recipients": "the-recipients",
    "source": "alert-source",
    "overwrite_quiet_hours": true,
    "tags": ["sensu"]
  }
}

Installation

Installation and Setup

Configuration

To get this to work you need to specify a few different things. For a list of fields that are required/available look at the sensu documentation. These files need to be on the server and the client boxes. Once there restart sensu-server and sensu-api.

  • declare this as a handler: /etc/sensu/conf.d/handler_opsgenie.json
{
  "handlers": {
    "opsgenie": {
      "type": "pipe",
      "command": "/opt/sensu/embedded/bin/handler-opsgenie.rb"
    }
  },
  "opsgenie": {
    "customerKey": "YOUR-KEY-HERE"
  }
}
  • add it to the check: /etc/sensu/conf.d/check_xxx.json
{
  "checks": {
    "check_elastinats_is_running": {
      "command": "/opt/sensu/embedded/bin/check-process.rb -p cron",
      "interval": 60,
      "handlers": [ "opsgenie" ],
      "subscribers": [ "core" ]
    }
  }
}
  • optionally add it to the default handler: /etc/sensu/conf.d/default_handler.json
{
  "handlers": {
    "default": {
      "type": "set",
      "handlers": [
        "opsgenie"
      ]
    }
  }
}

OpsGenie Alerts

How does the handler map the various Sensu values into the OpsGenie alerts and alert fields created?

Message

The OpsGenie message alert field is comprised of the Sensu client name, and the Sensu check name, e.g.:

web01 : check_mysql_access

Teams

The OpsGenie team alert field uses the values in the Sensu check configuration if any, otherwise it uses the value from the handler configuration.

Recipients

The OpsGenie recipients alert field uses the values in the Sensu check configuration if any, otherwise it uses the value from the handler configuration.

Alias

The OpsGenie alias alert is field is comprised of the Sensu client name, and the Sensu check name to create a unique key, e.g.:

web01:check_mysql_access

Note that this can be changed via configuration; see notes below.

Entity

The OpsGenie entity alert field uses the Sensu client name.

Description

The OpsGenie description alert field is populated with the Sensu check output.

Priority

The OpsGenie priority alert field is not explicitly set; OpsGenie will thus assign the default priority of "P3" to the alert.

Configuration Notes

Per Check Attributes

alias

If the check definition uses the custom alias attribute, e.g.:

{
  "checks": {
    "check_mysql_access": {
      "opsgenie": {
        "alias": "MyCustomAlias",

then the handler-opsgenie.rb handler will use that attribute value as the OpsGenie event ID. This can be useful for alert deduplication; checks on different clients for the same downstream resource can specify the same alias attribute, so that multiple alerts for the same resource are de-duplicated.

By default, handler-opsgenie.rb creates an event ID from the client name and the check name. Thus:

{
  "checks": {
    "check_mysql_access": {
      "command": "/opt/sensu/embedded/bin/check-database.rb -h mysqldb",
      "interval": 60,
      "handlers": [ "opsgenie" ],
      "standalone": true
    }
  }

running on a client named web01 will create an alert using an event ID of web01:check_mysql_access. And on a client named web02, it would create an alert with a different event ID of web02:check_mysql_access, even though the mysqldb server being checked is the same for these clients.

We can define a custom alias attribute in this check:

{
  "checks": {
    "check_mysql_access": {
      "command": "/opt/sensu/embedded/bin/check-database.rb -h mysqldb",
      "interval": 60,
      "handlers": [ "opsgenie" ],
      "standalone": true,

      "opsgenie": {
        "alias": "mysqldb"
      }
    }
  }

And with this, running on multiple clients, any alerts would be generated with the same event ID of mysqldb, by using that alias attribute as the event ID.

priority

By default, an OpsGenie alert is created with a default priority value of "P3". The priority for a specific check can be explicitly set using the custom priority attribute, e.g.:

{
  "checks": {
    "check_mysql_access": {
      "opsgenie": {
        "priority": "P1",

The list of valid values, per OpsGenie alert docs, are:

  • P1
  • P2
  • P3
  • P4
  • P5

Any value other than these will be ignored.

sensu-plugins-opsgenie's People

Contributors

tas50 avatar eheydrick avatar majormoses avatar castaglia avatar analytically avatar yanc0 avatar nhooey avatar mnellemann avatar evesy avatar tubaozturk avatar luisdalves avatar mattyjones avatar rgeniesse avatar rybit avatar sstarcher avatar dil-steti avatar

Watchers

James Cloos avatar

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.