Sensu Installation

The installation of sensu will involve first installation components that sensu depends on. So first we will install the required components, we would right doing this installation within a single node.

OS: Ubuntu Linux 14.04 server
Architecture: x86_64

Redis Installation

Since we are using the Ubuntu 14.04, we would want the add a ppa that provides a slightly newer version of the redis. So add the following ppa.

$ sudo add-apt-repository ppa:chris-lea/redis-server
$ sudo apt-get update

Then we proceed with the installation step.

$ sudo apt-get install redis-server

Set the ulimit in the /etc/default/redis-server file. Maybe anython greater than 4096

Since we are doing a basic standalone installation we would not be getting details of the how redis needs to configured, but keep this for reference.

Sensu Specific Configuration

Copy the following json block into /etc/sensu/conf.d/redis.json

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

Rabbit

We use Rabbit as the transport layer to transport message back and forth from sensu-server to sensu-client. Before installing RabbitMQ we need to install the right version of Erlang, as RabbitMQ does not work with the latest Elang version, so we have to pin that version to 19.3.6(esl-erlang).

# /etc/apt/preferences.d/erlang
Package: erlang*
Pin: version 1:19.3-1
Pin-Priority: 1000

Package: esl-erlang
Pin: version 1:19.3.6
Pin-Priority: 1000

Then we update the apt repos with esl sources.

$ sudo wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
$ sudo dpkg -i erlang-solutions_1.0_all.deb
$ sudo apt-get update

Now update the installation policy, install esl-erlang

$ sudo apt-cache policy
$ sudo apt-get install esl-erlang

Now set up sources for the rabbitmq repository, on the apt

$ echo 'deb http://www.rabbitmq.com/debian/ testing main' | \
     sudo tee /etc/apt/sources.list.d/rabbitmq.list

$ wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | \
 sudo apt-key add -

sudo apt-get update
sudo apt-get install rabbitmq-server
sudo  service rabbitmq-server start

Configure Rabbit

Since rabbitmq is a good full blown Message Broker, we need provide the right access points and privileges to. Create a dedicated RabbitMQ vhost for Sensu.

$ sudo rabbitmqctl add_vhost /sensu

Then create RabbitMQ user for Sensu

$ sudo rabbitmqctl add_user sensu secret
$ sudo rabbitmqctl set_permissions -p /sensu sensu ".*" ".*" ".*"

Sensu Specific Configuration

Copy the following contents to a configuration file located at /etc/sensu/conf.d/rabbitmq.json:

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

Sensu Server

Once you have installed Sensu’s prerequisites (RabbitMQ and Redis), you are ready to install a Sensu Server and API. Sensu Server and API are provided with Sensu Core package(OSS), installating this, would install the following programs

  • sensu-server
  • sensu-client
  • sensu-api

Installation

First setup the GPG Key for the Sensu

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

Since I am installing on trusty(Ubuntu 14.04), I will setup the lookup repo sources appropriately, and proceed to install

$ echo "deb     https://sensu.global.ssl.fastly.net/apt trusty main" \
| sudo tee /etc/apt/sources.list.d/sensu.list
$ sudo apt-get update
$ sudo apt-get install sensu

Ensure the following directories exist, otherwise create them.

  • /etc/sensu
  • /etc/sensu/conf.d

At this point ensure you complete the Configure Redis and Configure Rabbit sections by creating the /etc/sensu/conf.d/redis.json and /etc/sensu/conf.d/rabbitmq.json appropriately.

Now, create a client.json in the conf.d directory.

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

NOTE: The above configuration is a client only configuration.

Now tell sensu which transport to use for,(in our case it is rabbitmq), create a file named /etc/sensu/conf.d/transport.json.

{
    "transport": {
        "name": "rabbitmq",
        "reconnect_on_error": true
    }
}

Create the /etc/sensu/conf.d/api.json

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

It should be good to start the sensu services on your machine.

$ sudo service sensu-client start
$ sudo service sensu-server start
$ sudo service sensu-api start

Uchiwa Installation

Uchiwa is a dashboard implementation for the Sensu API. It has a minimalistic dashboard approach, and provides eye candy for monitoring your infrastructure. This describes the installation and configuration of the Uchiwa on top of the Sensu installation we just explained.

Install the GPG public key for the Uchiwa installation.

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

Since we are installing on trusty(ubuntu 14.04 we set up the installation repo sources appropriately, and proceed to install.

$ echo "deb     https://sensu.global.ssl.fastly.net/apt trusty main" \
| sudo tee /etc/apt/sources.list.d/uchiwa.list
$ sudo apt-get update
$ sudo apt-get install uchiwa

NOTE: The first step is redundant with setting of repo sources for sensu installation. You need to follow this if you are installing the uchiwa on different server.

Moving on the configuration create /etc/sensu/uchiwa.json file with the following contents.

{
    "sensu": [
        {
            "name": "Devsite",
            "host": "127.0.0.1",
            "port": 4567
        }
    ],
    "uchiwa": {
        "host": "0.0.0.0",
        "port": 8000
    }
}

This should setup the uchiwa to get data from the sensu-api and serve it at port 8000. More on the uchiwa configuration options could be found here.

NGINX Proxy to Uchiwa

Most case you would want to point a domain to your monitoring dashboard, say, monitoring.zig.pigs. So for this we would proxy all the http traffic through an nginx proxy.

Install nginx on your system

$ apt-get install nginx

Create a file, /etc/nginx/sites-available/monitoring.zig.pigs with the following configuration.

server {
    # nginx listens to this
    listen 80;

    # the virtual host name of this
    server_name monitoring.zig.pigs;

    location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://localhost:8000;
        proxy_http_version 1.1;
        proxy_pass_request_headers on;
        proxy_set_header Connection "keep-alive";
        proxy_store off;
    }
}

Note the proxy_pass directive in the above example config this means the NGINX is installed on the same server uchiwa is, but that need not be the case. And the link it into /etc/nginx/sites-enabled folder.

$ sudo ln -s /etc/nginx/sites-available/monitoring.zig.pigs /etc/nginx/sites-enabled/monitoring.zig.pigs

Restart the nginx server.

$ sudo service nginx restart

Now you should could point your browser to the http://monitoring.zig.pigs and you should be able to see the dashboard.

NOTE: I assume that your have made the appropriate DNS configurations for monitoring.zig.pigs.

Adding Checks

The primary goal of having a Sensu setup to monitor various aspects of your infrastructure, and if you are familiar with tools like Nagios, it done using using a concept called CHECKS. Checks is mechanism where periodic check is run for ascertain something some truth.

We in this example are going to use process-check to check if nginx process it running or not. First install the process-checks plugin.

$ sudo sensu-install -p process-checks:0.0.6

This installs the process-checks plugin on your machine. Its now time to tell, sensu-client to check for process, by creating a file called /etc/sensu/conf.d/check_nginx.json with following content.

{
    "checks": {
        "nginx": {
            "command": "check-process.rb -p nginx",
            "standalone": true,
            "interval": 60
        }
    }
}

Notice, nginx is the name of the check. Restart the sensu-client.

$ sudo service sensu-client restart

Check your dashboard for list of checks, it should now list the nginx.

Conclusion

Installation of Sensu and Uchiwa was a breeze, never thought I could get monitoring system up so easily. Except that you need to skim through page after page to get an installation going.

Show Comments