Jun 9, 2015 - Post Amazon CloudWatch alerts to your Slack


I wrote a Lambda script that let posts your Amazon CloudWatch alerts to your Slack.
I realized alerts by e-mail are kinda old-school already. In our company we never use e-mail internally anymore; The ONLY internal e-mail is server alerts.
So why not take that to Slack too?

Here it is:



Amazon Lambda to receive alerts from CloudWatch and post to Slack.

What is This?

It's an Amazon lambda script that receives data from Amazon CloudWatch via, then posts that result over to Slack. Just configure the javascript file and set it in Lambda, then you are good to go.

How to Use

Alarm configuration

In handler.js, you will find ALARM_CONFIG, which is the config for your alarms. You can set different configs for different alarm conditions, depending on the subject of the CloudWatch notification.

name description
condition The script will match the CloudWatch's subject for this value
channel Which channel to post to
mention any mentions you will want to direct it at
color color of the sidebar when posted in slack
severity Optional text indicating the severity, just displayed in the message

Slack configuration

In handler.js, you will find SLACK_CONFIG, which is the config for you Slack. Set the correct values in this.

name description
token The token for your webhook URL.
team The name of your team.

If you have trouble finding the above, Go here to set up your Incoming Webbhook integration for Slack,
Then find your Webhook URL. The configs will be:

Amazon CloudWatch configuration

Set whatever CloudWatch you want in your CloudWatch settings. Be sure to remember the SNS topic you send the alarms to.

Amazon Lambda configuration

  1. In the Lambda console panel, create a new Lambda function. Set the name to be whatever you want it to be.
  2. For the code of the Lambda function, copy and paste the handler.js file.
  3. After you have created the function, select add event sources for the Lambda function.
  4. In the event sources, select SNS and select the topic for which you've created on CloudWatch.

That is all. You should be receiving CloudWatch alerts on your Slack.

Testing, Debugging

When you want to debug/test your Lambda function, try using my lambda-local NPM.
It's a command-line tool that let's you execute Lambda functions on your local machine.


This library is released under the MIT license.

Apr 20, 2015 - Monty Hall Simulation


I never could understand the reasoning behind the Monty Hall Problem. Well, I could understand the reasoning, but I couldn't grasp the notion of how this can be true in real life.

There is a famous argument to this problem where it says "What if, right after the host opens one door, an alien appears from no where who has no prior information. Wouldn't the probability for choosing either door be 50/50 for it?". And I thought that was a very sound argument.

I decided to test it in real life with some python. Coincidentally this is Monty Python :)
So here's my code:


Yep, and as expected, the simulation always gives me an result of a 66.6% chance of success - Not 50%.

$ python run_montyhall.py y 100
{'Wrong': 35, 'Correct': 65}

So it seems like I will have to just go with the reasoning here.

Apr 16, 2015 - Back


I've been away from blogging for a while. Business has been prety hectic.
As a CTO of a growing startup, I am facing the inevitable decrease of coding time, and an increase of management time.
I have to proactively find time to code and try new things, otherwise my time gets filled up with non-technical matters more and more.

There are things I want to do - going deeper into Python(Django) and Ruby(Rails), trying out new PHP frameworks, trying Cassandra, reading into widely used open source projects, etc...

As a profession neck-deep into technology, I don't want to slow down my pace of learning new technologies. A challenge for my coming years...


Meanwhile, one thought I had which is worth noting here: