Difficulty: beginner
Estimated Time: 10-20 minutes

Welcome to Sensu Handlers 101.

In this lesson, we're going to cover handler basics. By the end of the lesson, you should be familiar enough with handlers to understand what role they play in the Sensu ecosystem and start writing your own.

Congrats! You've just created an entire pipeline! You created a check that is generating event data from a cpu check, and is sending that data on to Slack. It's simple, but effective, no?

You can complete this scenario now and continue on to the next one. We'll continue to build on the concepts you've learned here, so if you need to come back for a refresher, please do!

You can find the source for this scenario in GitHub.

Handlers 101

Step 1 of 4

What is a handler?

This lesson covers another one of Sensu's building blocks: Handlers. Handlers are designed to take some sort of action on the event data generated by checks. Handlers typically fall into one of several categories:

  • Alerting handlers (notify a human that something needs to happen)
  • Metric handlers (take metric data and ship it off to another application for storage & further processing)
  • Configuration handlers (use event data to communicate with an external source of truth)

Let's start by taking a look at an example alerting handler configuration for Slack.

api_version: core/v2
type: Handler
metadata:
  namespace: default 
  name: slack
spec:
  type: pipe
  runtime_assets:
  - slack-handler
  command: sensu-slack-handler --channel '#demo' --timeout 20 --username 'sensu' --webhook-url 'https://hooks.slack.com/services/XXXXXXXX/XXXXXXXXXX/XXXXXXXXXXXX 
  timeout: 30
  filters:
  - is_incident
  - not_silenced

There's quite a bit going on here, but the pattern should feel familiar and reminiscent of what you saw in the example check configuration.

Let's continue on and dissect what we have here.

Resources