Sensu is an open source monitoring tool that is capable of monitoring public, private, hybrid cloud, and container-based Infrastructure environments. Sensu has been designed to be simple, scalable and malleable framework that enables you to customize monitoring to meet the business needs. This guide will walk you through the installation of Sensu Go Monitoring Tool on CentOS 8 / RHEL 8 Linux machine.
Sensu Architecture
Sensu works in a Server-Client 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.
Install Sensu Go on CentOS 8 / RHEL 8
Follow the steps provided in this section to install Sensu Go on CentOS 8 / RHEL 8.
Step 1: Install Sensu Backend on CentOS 8 / RHEL 8
Add the backend repository:
curl -s https://packagecloud.io/install/repositories/sensu/stable/script.rpm.sh | sudo bash
If repository configuration was successful the output will look like below.
Complete!
Generating yum cache for sensu_stable...
Importing GPG key 0x0A3F7426:
Userid : "https://packagecloud.io/sensu/stable (https://packagecloud.io/docs#gpg_signing) <[email protected]>"
Fingerprint: CB16 05C4 E988 C91F 4382 49E3 A5BC 3FB7 0A3F 7426
From : https://packagecloud.io/sensu/stable/gpgkey
Generating yum cache for sensu_stable-source...
The repository is setup! You can now install packages.
..
After repository addition, install Sensu backend on CentOS 8 / RHEL 8:
sudo yum install sensu-go-backend
Accept installation prompt:
Transaction Summary
========================================================================================================================================================
Install 1 Package
Total download size: 14 M
Installed size: 38 M
Is this ok [y/N]: y
Step 2: Configure Sensu Backend on CentOS 8 / RHEL 8
Copy the config template from the docs:
sudo curl -L https://docs.sensu.io/sensu-go/latest/files/backend.yml -o /etc/sensu/backend.yml
Edit it to your liking:
sudo vi /etc/sensu/backend.yml
This is how my configuration looks like:
---
# Sensu backend configuration
# backend configuration
state-dir: "/var/lib/sensu/sensu-backend"
cache-dir: "/var/cache/sensu/sensu-backend"
config-file: "/etc/sensu/backend.yml"
debug: false
log-level: "debug" # available log levels: panic, fatal, error, warn, info, debug
##
# agent configuration
##
agent-port: 8081
##
# api configuration
##
api-listen-address: "[::]:8080" # listen on all IPv4 and IPv6 addresses
#api-url: "http://localhost:8080"
##
# dashboard configuration
##
#dashboard-cert-file: "/path/to/ssl/cert.pem"
#dashboard-key-file: "/path/to/ssl/key.pem"
dashboard-host: "[::]" # listen on all IPv4 and IPv6 addresses
dashboard-port: 3000
##
# ssl configuration
##
#cert-file: "/path/to/ssl/cert.pem"
#key-file: "/path/to/ssl/key.pem"
#trusted-ca-file: "/path/to/trusted-certificate-authorities.pem"
#insecure-skip-tls-verify: false
##
# store configuration
##
#etcd-advertise-client-urls: "http://localhost:2379"
#etcd-cert-file: "/path/to/ssl/cert.pem"
#etcd-client-cert-auth: false
#etcd-initial-advertise-peer-urls: "http://127.0.0.1:2380"
#etcd-initial-cluster: "default=http://127.0.0.1:2380"
#etcd-initial-cluster-state: "new" # new or existing
#etcd-initial-cluster-token: "sensu"
#etcd-key-file: "/path/to/ssl/key.pem"
#etcd-listen-client-urls: "http://127.0.0.1:2379"
#etcd-listen-peer-urls: "http://127.0.0.1:2380"
#etcd-name: "default"
#etcd-peer-cert-file: "/path/to/ssl/cert.pem"
#etcd-peer-client-cert-auth: false
#etcd-peer-key-file: "/path/to/ssl/key.pem"
#etcd-peer-trusted-ca-file: "/path/to/ssl/key.pem"
#etcd-trusted-ca-file: "/path/to/ssl/key.pem"
#no-embed-etcd: false
#etcd-cipher-suits
# - TLS_EXAMPLE
For a complete list of configuration options, see the backend reference.
Start Sensu backend service:
sudo systemctl enable --now sensu-backend
Check service status:
$ systemctl status sensu-backend
● sensu-backend.service - The Sensu Backend service.
Loaded: loaded (/usr/lib/systemd/system/sensu-backend.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2020-05-19 21:45:05 CEST; 14s ago
Main PID: 2194 (sensu-backend)
Tasks: 11 (limit: 26213)
Memory: 25.8M
CGroup: /system.slice/sensu-backend.service
└─2194 /usr/sbin/sensu-backend start -c /etc/sensu/backend.yml
May 19 21:45:11 cent8.geeksforgeeks.org sensu-backend[2194]: {"backend_id":"861176a0-1874-4007-be62-c41f1b048dfe","component":"metricsd","level":"d>
May 19 21:45:12 cent8.geeksforgeeks.org sensu-backend[2194]: {"backend_id":"861176a0-1874-4007-be62-c41f1b048dfe","component":"metricsd","level":"d>
May 19 21:45:13 cent8.geeksforgeeks.org sensu-backend[2194]: {"backend_id":"861176a0-1874-4007-be62-c41f1b048dfe","component":"metricsd","level":"d>
May 19 21:45:16 cent8.geeksforgeeks.org sensu-backend[2194]: {"component":"cache","level":"debug","msg":"rebuilding the cache for resource type *v2>
May 19 21:45:16 cent8.geeksforgeeks.org sensu-backend[2194]: {"component":"cache","level":"debug","msg":"rebuilding the cache for resource type *v2>
May 19 21:45:16 cent8.geeksforgeeks.org sensu-backend[2194]: {"component":"cache","level":"debug","msg":"rebuilding the cache for resource type *v2>
May 19 21:45:16 cent8.geeksforgeeks.org sensu-backend[2194]: {"component":"tessend","level":"debug","metric_name":"auth_provider_count","metric_val>
May 19 21:45:16 cent8.geeksforgeeks.org sensu-backend[2194]: {"backend_id":"861176a0-1874-4007-be62-c41f1b048dfe","component":"metricsd","level":"d>
May 19 21:45:17 cent8.geeksforgeeks.org sensu-backend[2194]: {"backend_id":"861176a0-1874-4007-be62-c41f1b048dfe","component":"metricsd","level":"d>
May 19 21:45:18 cent8.geeksforgeeks.org sensu-backend[2194]: {"backend_id":"861176a0-1874-4007-be62-c41f1b048dfe","component":"metricsd","level":"d>
Step 3: Initialize Sensu Backend
You now need to set up your Sensu administrator username and password. Run the following command to initialize the Sensu backend:
export SENSU_BACKEND_CLUSTER_ADMIN_USERNAME=admin
export SENSU_BACKEND_CLUSTER_ADMIN_PASSWORD=StrongAdminPassw0rd
sensu-backend init
Command execution output:
{"component":"backend.seeds","level":"info","msg":"seeding etcd store with intial data","time":"2020-05-19T21:50:07+02:00"}
You can also run the sensu-backend init command in interactive mode if you prefer to respond to prompts for your username and password:
sensu-backend init --interactive
More details about the sensu-backend init, see the backend reference documentation.
Step 4: Access Sensu Dashboard
The Sensu web UI provides a unified view of your monitoring events and user-friendly tools to reduce alert fatigue.
Confirm the UI service port is up.
$ sudo ss -tunelp | grep 3000
tcp LISTEN 0 128 *:3000 *:* users:(("sensu-backend",pid=2194,fd=18)) uid:994 ino:27800 sk:a v6only:0 <->
Check if the backend is up and running by querying API health:
$ curl http://127.0.0.1:8080/health
{"Alarms":null,"ClusterHealth":[{"MemberID":9882886658148554927,"MemberIDHex":"8927110dc66458af","Name":"default","Err":"","Healthy":true}],"Header":{"cluster_id":4255616304056076734,"member_id":9882886658148554927,"raft_term":2}}
If you have active firewall service, allow port 3000.
sudo firewall-cmd --add-port=3000/tcp --permanent
sudo firewall-cmd --reload
Open your browser and access Sensu dashboard on http://localhost:3000 or http://server_ip_or_hostname:3000.
Login with credentials set earlier.
Our next guides will cover installation of Sensu Agents and sensuctl command line tool.
Reference:
More on monitoring: