Set up Uptime Monitoring with Kibana, Heartbeat and Slack (Part 1)

Fatma Ali
3 min readApr 2, 2019

--

Uptime is an important aspect in any online hosted service as it directly impacts a business. You can have the best software product in the world, but if you experience a lot of downtime, then it’s as good as nothing. In the real world, 100% uptime is cannot be guaranteed. Thus the need to determine the moment downtime happens, and act fast.

Overtime, we also need to know more details, for example, what causes downtime, at what time it occurs etc. And that’s why at AMPATH, we chose to do it with Kibana and Heartbeat.

From the official websites:

Kibana lets you visualize your Elasticsearch data and navigate the Elastic Stack, so you can do anything from learning why you’re getting paged at 2:00 a.m. to understanding the impact rain might have on your quarterly numbers.

Heartbeat monitors services for their availability with active probing. Given a list of URLs, Heartbeat asks the simple question: Are you alive? Heartbeat ships this information and response time to the rest of the Elastic Stack for further analysis.

Both of these tools are part of the Elastic stack. You can find a quick intro to the Elastic stack here.

In the example below, we are going to set up Heartbeat to ping a HTTP server to determine if it’s up or down as well as configure Kibana to automatically create visualizations for the data received from heartbeat.

Step 1: Set up the ELK Stack

(Make sure you have docker and docker-compose installed before you begin!)

Fork and clone this repo. The docker-compose.yml file has the essential docker images for the ELK stack, we are going to have to add one more service for Heartbeat.

Addition of the hearbeat service to the docker-compose file

2: Configure Heartbeat

As you can see, we have added the heartbeat service to the compose file. But before we start the containers, we have to create the volumes we named in order to map the config file to the containers. So let’s create a folder named heartbeat. Inside the heartbeat folder:

(i) Create a Dockerfile with the following content:

Dockerfile for Heartbeat

(ii) Create a folder called config and inside the config folder, create a file called heartbeat.yml

The heartbeat.yml file is a config file that we’ll use to configure Heartbeat monitors. To better understand what it does, here’s how it should be written for our particular case:

Heartbeat config file for an http monitor

Brief Explanation

This file is responsible for configuring multiple heartbeat monitors. In our case, we have configured a single monitor of the http type. We have also instructed it to hit https://fatmali@github.io and https://google.com every 10 seconds with a GET request, if it gets a response with a 200 status code, then this means a server is up else it means it’s having some trouble. Finally, we have configured an Elasticsearch output and the Kibana host for automatic dashboard creation.

To learn more of about the http monitor and the different types of monitor heartbeat supports, head over to the official docs!

And that’s it, you’re ready to go!

Run:

$ sudo docker-compose up -d

And you should be up and running, once the containers have started, head over to Kibana and you should see the new Heartbeat dashboard automatically created. It should look like this:

The next part will cover how to utilize Elasticsearch Watchers to setup downtime notifications with Slack! Happy Monitoring 😉

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Fatma Ali
Fatma Ali

Written by Fatma Ali

Software Engineer, passionate about code, food & art. Bollywood dancer sometimes💃 Find me on GitHub https://github.com/fatmali

Responses (3)

Write a response