GithubHelp home page GithubHelp logo

bluekeyes / sensu-email-handler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sensu/sensu-email-handler

0.0 1.0 0.0 3.37 MB

Sensu Go Email Handler Plugin

Home Page: https://sensu.io

License: MIT License

Go 100.00%

sensu-email-handler's Introduction

Sensu Go Email Handler Plugin

TravisCI: TravisCI Build Status

The Sensu Go Email Handler is a Sensu Event Handler for sending incident notification emails.

Installation

Download the latest version of the sensu-email-handler from releases, or create an executable script from this source.

From the local path of the sensu-email-handler repository:

go build -o /usr/local/bin/sensu-email-handler main.go

Configuration

Example Sensu Go definition:

{
    "api_version": "core/v2",
    "type": "Handler",
    "metadata": {
        "namespace": "default",
        "name": "email"
    },
    "spec": {
        "type": "pipe",
        "command": "sensu-email-handler -f [email protected] -t [email protected] -s smtp.example.com -u user -p password",
        "timeout": 10,
        "filters": [
            "is_incident",
            "not_silenced"
        ]
    }
}

Usage Examples

Help

The Sensu Go Email handler for sending an email notification

Usage:
  sensu-email-handler [flags]

Flags:
  -T, --bodyTemplateFile string   A template file to use for the body
  -t, --toEmail string            The 'to' email address
  -f, --fromEmail string          The 'from' email address
  -h, --help                      help for sensu-email-handler
  -s, --smtpHost string           The SMTP host to use to send to send email
  -p, --smtpPassword string       The SMTP password, if not in env SMTP_PASSWORD
  -P, --smtpPort uint16           The SMTP server port (default 587)
  -u, --smtpUsername string       The SMTP username, if not in env SMTP_USERNAME
  -H, --hookout                   Include output from check hook(s)
  -i, --insecure                  Use an insecure connection (unauthenticated on port 25)
  -l, --enableLoginAuth           Use "login auth" mechanism
  -S, --subjectTemplate string    A template to use for the subject (default "Sensu Alert - {{.Entity.Name}}/{{.Check.Name}}: {{.Check.State}}")

Annotations

All of the above command line arguments can be overridden by check or entity annotations. The annotation consists of the key formed by appending the "long" argument specification to the string sensu.io/plugins/email/config (e.g. sensu.io/plugins/email/config/toEmail).

For example, having the following in an agent.yml file will create an entity annotation such that emails generated by events on this entity will go to [email protected] instead of the recipient defined in the handler. And the subject would be something to the effect of 'failing - webserver01/check-nginx'.

namespace: "default"
subscriptions:
  - linux
backend-url:
  - "ws://127.0.0.1:8081"
annotations:
  sensu.io/plugins/email/config/toEmail: "[email protected]"
  sensu.io/plugins/email/config/subjectTemplate: "{{.Check.State}} - {{.Entity.Name}}/{{.Check.Name}}",

Note: When using template expansion for annotations in checks, the token delimiters {{ and }} have to be escaped with {{` and `}}, respectively. Yes, this is ugly, but it is because checks are ran through token expansion before being ran. This is not needed for annotations in entities.

Example:

"sensu.io/plugins/email/config/subjectTemplate": "{{`{{ .Check.State }}`}} - {{`{{ .Entity.Name }}`}}/{{`{{ .Check.Name }}`}}",

Contributing

See https://github.com/sensu/sensu-go/blob/master/CONTRIBUTING.md

sensu-email-handler's People

Contributors

ccressent avatar fguimond avatar nixwiz avatar portertech avatar

Watchers

 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.