Welcome to our guide on How to Install Sensu Monitoring Tool on Ubuntu 22.04/20.04/18.04. 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.
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 22.04/20.04/18.04
In this section, Iāll show you the steps to installĀ the Sensu Monitoring Tool on Ubuntu 20.04/18.04 LTS. I assume you already have a running Ubuntu 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 update && sudo apt -y full-upgrade
[ -f /var/run/reboot-required ] && sudo reboot -f
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:
$ sudo ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
0.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 +0.000 0.000
1.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 +0.000 0.000
2.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 +0.000 0.000
3.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 +0.000 0.000
ntp.ubuntu.com .POOL. 16 p - 64 0 0.000 +0.000 0.000
*time.netzwerge. 31.209.85.242 2 u 1 64 1 9.574 +14.850 0.056
mail.kpprs.de 192.53.103.104 2 u 1 64 1 2.907 -1.920 0.016
sismox.com 187.182.182.166 3 u 2 64 1 0.675 -1.970 0.000
mail.klausen.dk 193.79.237.14 2 u 1 64 1 0.553 -2.043 0.005
2a01:4f8:c2c:3d 213.239.239.165 3 u 2 64 1 0.578 -1.960 0.002
node-1.infogral 17.253.14.123 2 u 1 64 1 0.529 -1.829 0.000
h2993508.strato 208.90.67.116 3 u 2 64 1 13.500 -2.122 0.009
alpha.rueckgr.a 205.46.178.169 2 u 1 64 1 2.897 -2.795 0.088
formularfetisch 185.248.188.98 2 u 2 64 1 2.850 -2.026 0.000
2620:2d:4000:1: 86.23.195.30 2 u 2 64 1 22.770 +2.248 0.000
ns1.idfnet.net 131.188.3.220 2 u 1 64 1 12.705 -0.005 0.000
Step 2: Install Sensu backend packages
Sensu backend package is available for Ubuntu/Debian, RHEL/CentOS, and Docker. Run the commands given to configure required repository that contains the packages.
$ curl -s https://packagecloud.io/install/repositories/sensu/stable/script.deb.sh | sudo bash
Detected operating system as Ubuntu/jammy.
Checking for curl...
Detected curl...
Checking for gpg...
Detected gpg...
Detected apt version as 2.4.9
Running apt-get update... done.
Installing apt-transport-https... done.
Installing /etc/apt/sources.list.d/sensu_stable.list...done.
Importing packagecloud gpg key... Packagecloud gpg key imported to /etc/apt/keyrings/sensu_stable-archive-keyring.gpg
done.
Running apt-get update... done.
The repository is setup! You can now install packages.
After the repository is added and functional we can then install the backend package:
sudo apt update
sudo apt install sensu-go-backend
Step 3: Configure Sensu and start services
There are two methods that can be used to configure Sensu backend. One is using sensu-backend start flags or /etc/sensu/backend.yml file.
Download the config template from the docs:
sudo curl -L https://docs.sensu.io/sensu-go/latest/files/backend.yml -o /etc/sensu/backend.yml
Then start sensu-backend using a systemd service manager
sudo systemctl start sensu-backend && sudo systemctl enable sensu-backend
Verify the status of the backend service:
$ systemctl status sensu-backend
ā sensu-backend.service - The Sensu Backend service.
Loaded: loaded (/lib/systemd/system/sensu-backend.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-08-16 12:45:55 EAT; 23s ago
Main PID: 6281 (sensu-backend)
Tasks: 7 (limit: 4523)
Memory: 29.1M
CPU: 466ms
CGroup: /system.slice/sensu-backend.service
āā6281 /usr/sbin/sensu-backend start -c /etc/sensu/backend.yml
Aug 16 12:46:15 jammy sensu-backend[6281]: {"cache_version":"v2","component":"cache","level":"debug","msg":"rebuilding the cache for resource type *v3.EntityConfig","time":"2023-08-16T12:46:15+03:0>
Aug 16 12:46:15 jammy sensu-backend[6281]: {"component":"etcd","level":"debug","caller":"v3rpc/interceptor.go:182","msg":"request stats","start time":"2023-08-16T12:46:15+03:00","time spent":"121.9>
Aug 16 12:46:15 jammy sensu-backend[6281]: {"component":"etcd","level":"debug","caller":"v3rpc/interceptor.go:182","msg":"request stats","start time":"2023-08-16T12:46:15+03:00","time spent":"242.3>
Aug 16 12:46:15 jammy sensu-backend[6281]: {"component":"tessend","level":"debug","metric_name":"check_count","metric_value":0,"msg":"collected a metric for tessen","time":"2023-08-16T12:46:15+03:0>
Aug 16 12:46:15 jammy sensu-backend[6281]: {"backend_id":"9d66f68d-9b30-4ead-81ce-4eb17adc65a6","component":"metricsd","level":"debug","msg":"metricsd heartbeat","name":"entity_metrics","time":"202>
Aug 16 12:46:15 jammy sensu-backend[6281]: {"component":"etcd","level":"debug","caller":"v3rpc/interceptor.go:182","msg":"request stats","start time":"2023-08-16T12:46:15+03:00","time spent":"313.0>
Aug 16 12:46:16 jammy sensu-backend[6281]: {"backend_id":"9d66f68d-9b30-4ead-81ce-4eb17adc65a6","component":"metricsd","level":"debug","msg":"metricsd heartbeat","name":"event_metrics","time":"2023>
Aug 16 12:46:16 jammy sensu-backend[6281]: {"component":"etcd","level":"debug","caller":"v3rpc/interceptor.go:182","msg":"request stats","start time":"2023-08-16T12:46:16+03:00","time spent":"262.3>
Aug 16 12:46:17 jammy sensu-backend[6281]: {"backend_id":"9d66f68d-9b30-4ead-81ce-4eb17adc65a6","component":"metricsd","level":"debug","msg":"metricsd heartbeat","name":"cluster_metrics","time":"20>
Aug 16 12:46:17 jammy sensu-backend[6281]: {"component":"etcd","level":"debug","caller":"v3rpc/interceptor.go:182","msg":"request stats","start time":"2023-08-16T12:46:17+03:00","time spent":"211.0>
For details about initializing the Sensu backend, read theĀ backend reference.
Step 4: Initialize Sensu by setting username and password
With the backend running, we need to run sensu-backend init
to set up Sensu administrator username and password.
Environment variables with a username and password string are needed for this.
sudo su -
export SENSU_BACKEND_CLUSTER_ADMIN_USERNAME=admin
export SENSU_BACKEND_CLUSTER_ADMIN_PASSWORD=StrongAdminPassw0rd
With the username and password provided, initialize Sensu:
# sensu-backend init
{"component":"cmd","level":"info","msg":"attempting to connect to etcd server: http://localhost:2379","time":"2023-08-16T12:47:36+03:00"}
{"component":"backend.seeds","level":"info","msg":"seeding etcd store with initial data","time":"2023-08-16T12:47:36+03:00"}
{"component":"store","level":"warning","msg":"migrating etcd database to a new version","time":"2023-08-16T12:47:36+03:00"}
{"component":"store","database_version":1,"level":"info","msg":"successfully upgraded database","time":"2023-08-16T12:47:36+03:00"}
{"component":"store","database_version":2,"level":"info","msg":"successfully upgraded database","time":"2023-08-16T12:47:36+03:00"}
{"component":"store","level":"warning","msg":"migrating enterprise etcd database to a new version","time":"2023-08-16T12:47:36+03:00"}
{"component":"store","database_version":1,"level":"info","msg":"successfully upgraded database","time":"2023-08-16T12:47:36+03:00"}
{"component":"store","database_version":2,"level":"info","msg":"successfully upgraded database","time":"2023-08-16T12:47:36+03:00"}
Check that the backend is up and running using Sensu /health
API to check the backendās health. You should receive a response that includes āHealthyā: true.
# curl http://127.0.0.1:8080/health
{"Alarms":null,"ClusterHealth":[{"MemberID":13195394291058371180,"MemberIDHex":"b71f75320dc06a6c","Name":"default","Err":"","Healthy":true}],"Header":{"cluster_id":2037210783374497686,"member_id":13195394291058371180,"raft_term":2}}
Step 5: Access Sensu Web UI
The Web UI service is listening on port 3000
# ss -tunelp | grep 3000
tcp LISTEN 0 4096 *:3000 *:* users:(("sensu-backend",pid=6281,fd=20)) uid:998 ino:61297 sk:13 cgroup:/system.slice/sensu-backend.service v6only:0 <->
The web UI provides a unified view of your observability events and user-friendly tools to reduce alert fatigue. Open the web UI by visiting http://serverIP:3000.
Login with the username and password set in Step 4. For us the username was admin & password is StrongAdminPassw0rd
Step 6: Install sensuctl
SensuctlĀ is a command line utility that enables you to manage resources within Sensu. It calls the Sensuās HTTP API to create, read, update, and delete resources, events, and entities. This tool can be installed on Linux, Windows, and macOS.
apt install sensu-go-cli
RunĀ sensuctl configure
Ā and log in with your user credentials, namespace, and Sensu backend URL.
# Syntax
sensuctl configure -n \
--username 'YOUR_USERNAME' \
--password 'YOUR_PASSWORD' \
--namespace default \
--url 'http://127.0.0.1:8080'
# Example
sensuctl configure -n \
--username 'admin' \
--password 'StrongAdminPassw0rd' \
--namespace default \
--url 'http://127.0.0.1:8080'
To view your profile run the commands below:
# sensuctl config view
=== Active Configuration
API URL: http://127.0.0.1:8080
Namespace: default
Format: tabular
Timeout: 15s
Username: admin
JWT Expiration Timestamp: 1665750798
More guides: