<commit_before>---
layout: post
title:  "CHEF slack notifications"
date:   2015-08-16 10:55:00
categories: chef slack  

---

# Event Handlers

Occasionally in your automation infrastructure, you want an event to trigger a notification. For example, everytime a chef run fails, send an alert. Or everytime a webserver reboots, send an email. 

Chef handles this beautifuly with [event handlers](https://docs.chef.io/handlers.html). 

Basically an event handler is a ruby script that chef calls on a defined trigger. 

# Slack

In my infrastructure, we are adopting slack for both communication and notificaitons. Slack is simple, beautiful and powerful. 

There is a community of chef handlers for [many external services](https://docs.chef.io/handlers.html#community-handlers) such as: 

- IRC
- Email
- GrayLog2
- DataDog
- Graphite

Here is how simple it is to add slack notifications to a cookbook. 

<script src="https://gist.github.com/spuder/6723fec3729125a25264.js"></script>
<commit_msg>fixes slack date<commit_after>---
layout: post
title:  "CHEF send Slack notifications"
date:   2015-10-16 10:55:00
categories: chef slack  

---

# Event Handlers

Occasionally in your automation infrastructure, you want an event to trigger a notification. For example, everytime a chef run fails, send an alert. Or everytime a webserver reboots, send an email. 

Chef handles this beautifuly with [event handlers](https://docs.chef.io/handlers.html). 

Basically an event handler is a ruby script that chef calls on a defined trigger. 

# Slack

In my infrastructure, we are adopting slack for both communication and notificaitons. Slack is simple, beautiful and powerful. 

There is a community of chef handlers for [many external services](https://docs.chef.io/handlers.html#community-handlers) such as: 

- IRC
- Email
- GrayLog2
- DataDog
- Graphite

Here is how simple it is to add slack notifications to a cookbook. 

<script src="https://gist.github.com/spuder/6723fec3729125a25264.js"></script>

{'fraction_non_alphanumeric': 0.081, 'fraction_numerical': 0.031, 'mean_word_length': 4.157216494845361, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5655682', 'n_tokens_mistral': 662, 'n_tokens_neox': 573, 'n_words': 243}