Monitoring Elasticsearch Cluster Health in Slack

description

We’ve been very happy Slack users since November 2013 — over a year! We use Slack for communication and collaboration.

We also use Slack to centralize other sorts of information such as service status RSS feeds (like the AWS EC2 NoVa status feed or Ubuntu security alerts), Twitter feeds (to keep track of news from @jquery or Jeffery Way’s awesome @laracasts), software releases (like Laravel or Gulp), and so on.

We’ve also been migrating our monitoring and alerting from email to Slack, as well.

We manage Elasticsearch clusters, and we wanted to get basic alerting for Elasticsearch into Slack. In moments, our ace system administrator Alex deployed some shell scripts we can easily run with cron. (He makes all this stuff look easy!)

Using Curl:

#!/bin/bash

STATUS=`/usr/bin/curl -s your-es-server:9200/_cluster/health?pretty|grep status|awk '{print $3}'|cut -d\" -f2`

if [[ "$STATUS" != "green" ]]; then

    curl -X POST --data-urlencode 'payload={"text": "Danger! Your desired Elasticsearch alert text here!"}' https://hooks.slack.com/services/path/to/your/slackhook

fi

Using Nagios (and Slack’s slack_nagios.pl):

#!/bin/bash

STATUS=`/usr/bin/curl -s your-es-server:9200/_cluster/health?pretty|grep status|awk '{print $3}'|cut -d\" -f2`

       if [[ "$STATUS" != "green" ]]; then

/usr/local/bin/slack_nagios.pl -field slack_channel=#your-slack-channel -field HOSTALIAS="your-host.com" -field SERVICEDESC="ElasticSearch" -field SERVICESTATE="CRITICAL" -field SERVICEOUTPUT="Status=$STATUS"

fi

Of course, you’ll need to tweak either script to get them to work with your setup!

If you want Alex and the rest of our team to help keep your web application fast, stable, and secure, we’re only an email or phone call (1.877.439.6665) away!

Let’s Work Together. Tell us what you’re looking for. How can we help?

contact us