GithubHelp home page GithubHelp logo

bwits / rancher-alarms Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ndelitski/rancher-alarms

0.0 2.0 0.0 39 KB

Will kick your ass if found unhealthy service in Rancher environment

JavaScript 93.53% Shell 6.47%

rancher-alarms's Introduction

rancher-alarms

Send notifications when something goes wrong in rancher

Features

  • Will kick your ass when service state is not okay
  • Various notification mechanisms
    • email
    • and more will be later...
  • Configure notification mechanisms globally or on a per service level

Run in Docker

docker run \
    -d \
    -e CONFIG_FILE=/etc/rancher-alarms/config.json \
    -v $(pwd)/config.json:/etc/rancher-alarms/config.json \
    --name rancher-alarms \
    ndelitski/rancher-alarms:0.1.0

Docker compose

rancher-alarms:
  image: ndelitski/rancher-alarms:0.1.0
  environment:
    RANCHER_ADDRESS: rancher.yourdomain.com[:port]
    RANCHER_ACCESS_KEY: AccessKEY
    RANCHER_SECRET_KEY: SECRETkey
    RANCHER_PROJECT_ID: i8a
    ALARM_EMAIL_ADDRESSES: [email protected],[email protected]
    ALARM_EMAIL_USER: [email protected]
    ALARM_EMAIL_PASS: nightWatch
    ALARM_EMAIL_SMTP_HOST: smtp.snow.com
    ALARM_EMAIL_FROM: 'Alarm of a Night Watch <[email protected]>'
  tty: true

How it works

On startup get a list of services and instantiate healthcheck monitor for each of them if service is in a running state. Removed, purged and etc services will be ignored

List of healthcheck monitors is updated with pollServicesInterval interval. When service is removed it will be no longer monitored.

When service become degraded state all targets will be invoked to process notification.

Configuration

{
    "rancher": {
        "address": "rancher-host:port",
        "auth": {
            "accessKey": "<ACCESS_KEY>",
            "secretKey": "<KEEP_YOUR_SECRETS_SAFE>"
        },
        "projectId": "1a5"
    },
    "pollServicesInterval": 10000,
    "filter": [
        "frontend"
    ],
    "notifications": {
        "*": {
            "targets": {
                "email": {
                    "recipients": [
                        "[email protected]"
                    ]
                }
            },
            "healthcheck": {
                "pollInterval": 5000,
                "healthyThreshold": 2,
                "unhealthyThreshold": 3
            },
        },
        "backend": {
            "targets": {
                "sms": {
                    "phones": [
                        "+122233344"
                    ]
                }
            }
        },
        "frontend": {
            "targets": {
                "http": {
                    "endpoint": "http://will-hit.this/endpoint"
                }
            }
        }
    },
    "targets": {
        "email": {
            "smtp": {
                "from": "<Alarm Service> [email protected]",
                "auth": {
                    "user": "[email protected]",
                    "password": "Str0ngPa$$"
                },
                "host": "smtp.gmail.com",
                "secureConnection": true,
                "port": 465
            }
        }
    }
}

Sections

  • rancher Rancher API settings. required
  • pollServicesInterval interval in ms of fetching list of services. required.
  • filter whitelist filter for stack/services names in environment. List of string values. Every string is a RegExp expression so you can use something like this to match all stack services frontend/*. optional
  • notifications per service notification settings. Wildcard means any service required
    • healtcheck monitoring state options. optional defaults are:
    {
      pollInterval: 5000,
      healthyThreshold: 2,
      unhealthyThreshold: 3
    }
    • targets what notification targets to use. Will override base target settings in a root targets section. Currently each target must be an Object value. If you have nothing to override from a base settings just place {} as a value. optional
  • targets base settings for each notification target. required

Supported notification targets

  • email

Roadmap

  • Simplify configuration.
  • More use of rancher labels and metadata. Alternate configuration through rancher labels/metadata(can be used in a conjunction with initial config).
  • Run in a rancher environment as an agent with a new label agent: true. No need to specify keys anymore!
  • More notifications mechanisms: AWS SNS, http, sms
  • Better email template
  • Test coverage. Setup drone.io
  • Notify when all services operate normal after some of them were in a degraded state
  • Refactor notifications

rancher-alarms's People

Contributors

ndelitski avatar

Watchers

 avatar  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.