Select Supported Platforms

Select Supported Architectures

Select Tier

Github Name

Asset Definition
Release Notes
Release Assets

Bonsai Asset Badge

Sensu Email Handler


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

Usage Examples


The Sensu Email handler sends an email notifications

  sensu-email-handler [flags]

  -a, --authMethod string         The SMTP authentication method, one of 'none', 'plain', or 'login' (default "plain")
  -T, --bodyTemplateFile string   A template file to use for the body
  -l, --enableLoginAuth           [deprecated] Use "login auth" mechanisim
  -f, --fromEmail string          The 'from' email address
  -h, --help                      help for sensu-email-handler
  -H, --hookout                   Include output from check hook(s)
  -i, --insecure                  [deprecated] Use an insecure connection (unauthenticated on port 25)
  -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 uint             The SMTP server port (default 587)
  -u, --smtpUsername string       The SMTP username, if not in env SMTP_USERNAME
  -S, --subjectTemplate string    A template to use for the subject (default "Sensu Alert - {{.Entity.Name}}/{{.Check.Name}}: {{.Check.State}}")
  -k, --tlsSkipVerify             Do not verify TLS certificates
  -t, --toEmail string            The 'to' email address


Asset registration

Assets are the best way to make use of this handler. If you're not using an asset, please consider doing so! If you're using sensuctl 5.13 or later, you can use the following command to add the asset:

sensuctl asset add sensu/sensu-email-handler

If you're using an earlier version of sensuctl, you can download the asset definition from this project's Bonsai Asset Index page.

Asset definition

type: Asset
api_version: core/v2
  name: sensu-email-handler_linux_amd64
    io.sensu.bonsai.tier: Supported
    io.sensu.bonsai.version: 0.2.0
    io.sensu.bonsai.namespace: sensu sensu-email-handler
    io.sensu.bonsai.tags: handler
  sha512: d69df76612b74acd64aef8eed2ae10d985f6073f9b014c8115b7896ed86786128c20249fd370f30672bf9a11b041a99adb05e3a23342d3ad80d0c346ec23a946
  - entity.system.os == 'linux'
  - entity.system.arch == 'amd64'

Handler definition

api_version: core/v2
type: Handler
  namespace: default
  name: email
  type: pipe
  command: sensu-email-handler -f -t -s
    -u user -p password
  timeout: 10
  - is_incident
  - not_silenced
  - sensu/sensu-email-handler


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 (e.g.

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 instead
of the recipient defined in the handler. And the subject would be something to the effect
of 'failing - webserver01/check-nginx'.

namespace: "default"
  - linux
  - "ws://"
annotations: "" "{{.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.


"": "{{`{{ .Check.State }}`}} - {{`{{ .Entity.Name }}`}}/{{`{{ .Check.Name }}`}}",


The plugin provides an option to use a template as for the body of the email and is capable of using HTML for formatting the email. An example is provided below:



<h3>Informational Details</h3>
<b>Check</b>: {{ .Check.Name }}
<b>Entity</b>: {{ .Entity.Name }}
<b>State</b>: {{ .Check.State }}
<b>Occurrences</b>: {{ .Check.Occurrences }}
<h3>Check Output Details</h3>
<b>Check Output</b>: {{.Check.Output}}
<h4>Check Hook(s)</h4>
{{range .Check.Hooks}}<b>Hook Name</b>:  {{.Name}}
<b>Hook Command</b>:  {{.Command}}
<b>Hook Output</b>: {{.Output}}



Note that this uses tokens to populate the values provided by the event.

Also note that line breaks in your template and any text surfaced by token substitution are replaced with the HTML <br> tag.

At the time of this example, check hooks and templates are not able to be used together via the -H and -T flags. However, you may include the hook output as part of the template via the following:

{{range .Check.Hooks}}
Hook Name:  {{.Name}}
Hook Command:  {{.Command}}

Installing from source and contributing

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

For additional instructions, see CONTRIBUTING

Are you sure you want to report this asset?

Please describe the reason for reporting this asset. Our moderators will be notified and will disable the asset if it is found to be inappropriate.


You must be signed in to report this asset.

Sign In with Github



Either download the source code:

Download Source

Or download the asset definition: