Step-by-Step Guide: Installing Sensu Monitoring on Ubuntu 20.04

Sensu is a versatile and open-source platform for monitoring the health of infrastructure and applications. Created with Ruby, Sensu leverages RabbitMQ to handle messages and Redis for data storage. Compatible with multiple operating systems like Ubuntu, Debian, RHEL, CentOS, FreeBSD, macOS, Solaris, and Windows, Sensu is a next-generation monitoring tool favored over systems like Zabbix, Icinga, and Nagios. It employs a client-server architecture, requiring installation of the Sensu client on every system you wish to monitor.

In this guide, we will demonstrate the installation of a Sensu monitoring server on an Ubuntu 20.04 system.

Prerequisites

  • An Ubuntu 20.04 server.
  • Root password configured on the server.

Getting Started

Begin by updating your system to the latest stable version by running:

apt-get update -y

Install necessary dependencies with:

apt-get install gnupg2 curl wget unzip -y

After installing all necessary packages, move on to the next step.

Install Redis and RabbitMQ

Since Sensu relies on RabbitMQ and Redis, you must install these on your system. RabbitMQ is not included in the default Ubuntu 20.04 repository, so begin by adding its repository.

Import the GPG key:

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

Add the repository with:

echo "deb http://binaries.erlang-solutions.com/debian $(lsb_release -cs) contrib" | tee /etc/apt/sources.list.d/erlang-solutions.list

Update the repository and install RabbitMQ:

apt-get update -y
apt-get install rabbitmq-server -y

Create a RabbitMQ vhost for Sensu:

rabbitmqctl add_vhost /sensu

Expected output:

Adding vhost "/sensu" ...

Create a user to manage the vhost:

rabbitmqctl add_user sensu password

Expected output:

Adding user "sensu" ...

Assign full permissions to the vhost /sensu:

rabbitmqctl set_permissions -p /sensu sensu ".*" ".*" ".*"

Expected output:

Setting permissions for user "sensu" in vhost "/sensu" ...

Install Redis:

apt-get install redis-server -y

Start the Redis service and enable it:

systemctl start redis-server
systemctl enable redis-server

Proceed to the next step once finished.

Install Sensu Server

Since Sensu is not present in the official Ubuntu repository, add the Sensu repository:

Import the repository GPG key:

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

Add the repository:

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

Update the repository and install Sensu:

apt-get update -y
apt-get install sensu -y

Configure Sensu

Configure RabbitMQ, Redis, and API by creating configuration files.

Create an api.json file:

nano /etc/sensu/conf.d/api.json

Include:

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

Create a redis.json file:

nano /etc/sensu/conf.d/redis.json

Include:

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

Create a RabbitMQ configuration file:

nano /etc/sensu/conf.d/rabbitmq.json

Include:

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

Install and Configure Sensu Dashboard

Install the Uchiwa dashboard for web-based monitoring:

apt-get install uchiwa -y

Create a Uchiwa configuration file:

nano /etc/sensu/uchiwa.json

Include:

{
    "sensu": [
      {
        "name": "Sensu",
        "host": "127.0.0.1",
        "port": 4567,
        "timeout": 10
      }
    ],
    "uchiwa": {
      "host": "0.0.0.0",
      "port": 3000,
      "refresh": 10
    }
  }

Create a client.json file to monitor the Sensu server:

nano /etc/sensu/conf.d/client.json

Include:

{
    "client": {
      "name": "sensu-server",
      "address": "127.0.0.1",
      "environment": "management",
      "subscriptions": [
        "dev",
        "ubuntu"
      ],
      "socket": {
        "bind": "127.0.0.1",
        "port": 3030
      }
    }
  }

Start the Sensu services:

systemctl start sensu-server
systemctl start sensu-api
systemctl start uchiwa
systemctl start sensu-client

Check the status of these services:

systemctl status sensu-server sensu-api sensu-client uchiwa

Expected output:

? sensu-server.service - sensu server
     Loaded: loaded (/lib/systemd/system/sensu-server.service; disabled; vendor preset: enabled)
     Active: active (running) since Sun 2020-08-23 09:04:43 UTC; 4min 18s ago
   Main PID: 10031 (sensu-server)
      Tasks: 24 (limit: 2353)
     Memory: 20.6M
     CGroup: /system.slice/sensu-server.service
             ??10031 /opt/sensu/embedded/bin/ruby /opt/sensu/bin/sensu-server -c /etc/sensu/config.json -d /etc/sensu/conf.d -e /etc/sensu/ext>
 
Aug 23 09:04:43 ubuntu2004 systemd[1]: Started sensu server.

? sensu-api.service - sensu api
     Loaded: loaded (/lib/systemd/system/sensu-api.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2020-08-23 09:04:42 UTC; 4min 19s ago
   Main PID: 10023 (sensu-api)
      Tasks: 2 (limit: 2353)
     Memory: 18.9M
     CGroup: /system.slice/sensu-api.service
             ??10023 /opt/sensu/embedded/bin/ruby /opt/sensu/bin/sensu-api -c /etc/sensu/config.json -d /etc/sensu/conf.d -e /etc/sensu/extens>

Aug 23 09:04:42 ubuntu2004 systemd[1]: Started sensu api.

? sensu-client.service - sensu client
     Loaded: loaded (/lib/systemd/system/sensu-client.service; disabled; vendor preset: enabled)
     Active: active (running) since Sun 2020-08-23 09:04:42 UTC; 4min 18s ago
   Main PID: 10027 (sensu-client)
      Tasks: 2 (limit: 2353)
     Memory: 17.0M
     CGroup: /system.slice/sensu-client.service
             ??10027 /opt/sensu/embedded/bin/ruby /opt/sensu/bin/sensu-client -c /etc/sensu/config.json -d /etc/sensu/conf.d -e /etc/sensu/ext>
 
Aug 23 09:04:42 ubuntu2004 systemd[1]: sensu-client.service: Succeeded.
Aug 23 09:04:42 ubuntu2004 systemd[1]: Stopped sensu client.
Aug 23 09:04:42 ubuntu2004 systemd[1]: Started sensu client.

? uchiwa.service - LSB: Uchiwa, a Sensu dashboard.
     Loaded: loaded (/etc/init.d/uchiwa; generated)
     Active: active (exited) since Sun 2020-08-23 09:04:41 UTC; 4min 19s ago

Access Sensu Dashboard

To access the dashboard, open your web browser and visit http://your-server-ip:3000. You should see a screen similar to this:

Sensu Monitoring Tool

Click on the client icon in the left pane to view the Sensu client status:

Sensu dashboard

Conclusion

Congratulations! You have successfully installed and configured Sensu with Uchiwa on Ubuntu 20.04. You can now add more clients and commence monitoring through the Uchiwa dashboard. If you have any questions, feel free to reach out for assistance.

Frequently Asked Questions (FAQ)

What is Sensu?
Sensu is an open-source platform for monitoring infrastructure and application health, using RabbitMQ and Redis for message handling and data storage, respectively.
Which operating systems support Sensu?
Sensu is compatible with various systems, including Ubuntu, Debian, RHEL, CentOS, FreeBSD, macOS, Solaris, and Windows.
Is RabbitMQ essential for Sensu to function?
Yes, RabbitMQ is crucial for Sensu as it handles messaging throughout the platform.
How can I access the Sensu dashboard?
Access the dashboard by visiting http://your-server-ip:3000 in a web browser.
Where can I find more information on Sensu configuration?
For more details, consult the Sensu documentation or community forums for guidance on advanced configuration and usage.