(Last Updated On: September 10, 2018)

Welcome to our guide on How to Install Sensu Monitoring Tool on Ubuntu 18.04 LTS. Sensu is an open-source, full-stack monitoring tool suitable for any kind of dynamic operating environments. It is a simple, scalable and malleable framework that helps you compose the monitoring system you need.

Introduction to Sensu Monitoring Tool

Sensu is capable of monitoring public, private, and hybrid cloud, and container-based environments. It is written in Ruby and uses RabbitMQ for queuing check events and requests. Data that needs persistent storage like client information are stored in Redis. Sensu ships with a ton of plugins for monitoring common services.

How Sensu Works

Sensu uses a client-server model where all systems to be monitored runs a sensu client software. This client application is responsible for executing local checks, managing client subscription and registration, and fulfilling checks requested by the Sensu Server. The agent reports the results of a check and the server will take action based on the results, e.g sending a notification message to the user if the service is down.

Install Sensu Monitoring Tool on Ubuntu 18.04 LTS

In this section, I’ll show you the steps to install the Sensu Monitoring Tool on Ubuntu 18.04 LTS. I assume you already have a running Ubuntu 18.04 server, it can be a VM locally, in the Cloud, or a dedicated server.

Step 1: Set server hostname, ntp, and update

Always start your installations by updating system package to the latest version.

sudo apt-get update
sudo apt-get -y upgrade
sudo reboot

Wait for the server to come up then set hostname

sudo hostnamectl set-hostname sensu.example.com

Setup NTP and Timezone

It is good to have NTP configured on both Sensu server and agents for correct timestamp on all data.

Set correct timezone

sudo timedatectl set-timezone Africa/Nairobi

Install ntp package

sudo apt -y install ntp

Show ntp status

ntpq -p

Step 2: Install Redis and RabbitMQ

RabbitMQ runs on the Erlang runtime, you need to import GPG key:

wget -O- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | sudo apt-key add -

Add Erlang repository using below command:

wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb

Install RabbitMQ

$ sudo apt -y install rabbitmq-server

When done, Create a RabbitMQ vhost for Sensu

$ sudo rabbitmqctl add_vhost /sensu
Creating vhost "/sensu"

Add user to manage the vhost

$ sudo rabbitmqctl add_user sensu  StrongPassword
Creating user "sensu"

Replace StrongPassword with your password.

Assing sensu user full permissions for the vhost /sensu

$ sudo rabbitmqctl set_permissions -p /sensu sensu ".*" ".*" ".*"
Setting permissions for user "sensu" in vhost "/sensu"

Install Redis Server

sudo apt -y install redis-server

Step 3: Install and Configure Sensu

Sensu packages are not available on official Ubuntu repository. You’ll need to add the upstream repository before you can install sensu package.

echo "deb https://sensu.global.ssl.fastly.net/apt bionic main" | sudo tee /etc/apt/sources.list.d/sensu.list

Import repository GPG key

wget -O- https://sensu.global.ssl.fastly.net/apt/pubkey.gpg | sudo apt-key add -

Update package index and install sensu

sudo apt update
sudo apt -y install sensu

Sensu configuration files, plugins and extensions will be placed under the /etc/sensu/directory.

Create sensu configuration file for connecting to RabbitMQ, API and Redis

Create API configuration file:

$ sudo vim /etc/sensu/conf.d/api.json

{
  "api": {
    "host": "localhost",
    "bind": "0.0.0.0",
    "port": 4567
  }
}

Create RabbitMQ access config:

$ sudo vim /etc/sensu/conf.d/rabbitmq.json

{
  "rabbitmq": {
    "host": "127.0.0.1",
    "port": 5672,
    "vhost": "/sensu",
    "user": "sensu",
    "password": "StrongPassword"
  }
}

Redis config:

$ sudo vim /etc/sensu/conf.d/redis.json

{
  "redis": {
    "host": "127.0.0.1",
    "port": 6379
  }
}

Step 4: Install and Configure Uchiwa Sensu web interface

Install uchiwa by running:

sudo apt -y install uchiwa

Create configuration file

$ sudo vim /etc/sensu/conf.d/uchiwa.json
{
  "sensu": [
    {
      "name": "sensu.example.com",
      "host": "127.0.0.1",
      "port": 4567,
      "timeout": 10
    }
  ],
  "uchiwa": {
    "host": "0.0.0.0",
    "port": 3000,
    "refresh": 10,
    "user": "admin",
    "pass": "AdminAassword"
  }
}

Configure Sensu client

$ sudo vim /etc/sensu/conf.d/client.json
{
  "client": {
    "environment": "development",
    "name": "sensu-server",
    "address": "127.0.0.1",
    "subscriptions": [
      "development",
      "sensu-server"
    ]
  }
}

Set permissions:

sudo chown sensu. /etc/sensu/conf.d/*

Step 5: Start Sensu Service

You can now start sensu services and enable them to start on boot

for i in sensu-server sensu-api sensu-client uchiwa; do
  sudo systemctl enable $i
  sudo systemctl start $i
done

Access Sensu Dashboard using http://[ip|hostname]:3000

Login with configured username and password.