{"id":12595,"date":"2022-05-07T00:14:32","date_gmt":"2022-05-06T21:14:32","guid":{"rendered":"https:\/\/kifarunix.com\/?p=12595"},"modified":"2024-03-09T14:22:08","modified_gmt":"2024-03-09T11:22:08","slug":"install-sensu-go-on-ubuntu","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-sensu-go-on-ubuntu\/","title":{"rendered":"Install Sensu Go on Ubuntu 22.04"},"content":{"rendered":"\n

In this tutorial to learn how to install Sensu Go on Ubuntu 22.04. Sensu<\/a> is an opensource infrastructure and application monitoring tool.<\/p>\n\n\n\n

Install Sensu Go on Ubuntu 22.04<\/h2>\n\n\n\n

Minimum System Hardware Requirements<\/h3>\n\n\n\n

Before you can proceed, check the recommended system hardware requirements<\/a>.<\/p>\n\n\n\n

Deployment Architecture<\/h3>\n\n\n\n

There are different deployment architectures<\/a> for Sensu Go. We will use standalone deployment in this guide.<\/p>\n\n\n\n

Install Sensu Go;<\/h3>\n\n\n\n

Sensu Go works in a client-server architecture with the Sensu Backend serving as the server while Sensu agent serving as the client.<\/p>\n\n\n\n

According to Sensu component reference page;<\/p>\n\n\n\n

Sensu Backend is a service that manages check requests and observability data. Every Sensu backend includes an integrated structure for scheduling checks using subscriptions, an event processing pipeline that applies event filters, mutators, and handlers, an embedded etcd datastore for storing configuration and state, and the Sensu API, Sensu web UI, and sensuctl command line tool<\/em>.<\/p>\n\n\n\n

The Sensu agent is a lightweight client that runs on the infrastructure components you want to monitor. Agents register with the Sensu backend as monitoring entities with type: \"agent\"<\/code>. Agent entities are responsible for creating check and metrics events to send to the backend event pipeline.<\/em><\/p>\n\n\n\n

Install Sensu Go Backend on Ubuntu 22.04<\/h3>\n\n\n\n

You would easily install Sensu from the APT repositories. However, as of this writing, there are not Sensu repos made for Ubuntu 22.04 yet.<\/p>\n\n\n\n

Therefore, you if you really need to run Sensu Go on Ubuntu 22.04, then consider using Ubuntu 20.04 Focal Sensu APT repositories.<\/p>\n\n\n\n

wget https:\/\/packagecloud.io\/install\/repositories\/sensu\/stable\/script.deb.sh<\/code><\/pre>\n\n\n\n
os=ubuntu dist=focal bash .\/script.deb.sh<\/code><\/pre>\n\n\n\n

Install Sensu Go backend;<\/p>\n\n\n\n

sudo apt update<\/code><\/pre>\n\n\n\n
sudo apt install sensu-go-backend<\/code><\/pre>\n\n\n\n

Install Sensu Go Command Line tool;<\/h3>\n\n\n\n

Run the command below to install Sensu Go command line tool that helps you to control Sensu Go resources.<\/p>\n\n\n\n

sudo apt install sensu-go-cli<\/code><\/pre>\n\n\n\n

The binary that sensu-go-cli installs is called sensuctl<\/code><\/strong>.<\/p>\n\n\n\n

Configure and Start Sensu Go Backend on Ubuntu 22.04<\/h3>\n\n\n\n

You can start Sensu and run it on the foreground or run it as a service.<\/p>\n\n\n\n

To run it on the foreground, just execute the command below;<\/p>\n\n\n\n

sudo -u sensu sensu-backend start<\/code><\/pre>\n\n\n\n

Press Ctrl+c<\/code><\/strong> to stop.<\/p>\n\n\n\n

You can learn about the usage of the command sensu-backend from the help page.<\/p>\n\n\n\n

sensu-backend --help<\/code><\/pre>\n\n\n\n

To run Sensu as a service, download the sample configuration by running the command below;<\/p>\n\n\n\n

curl -sL https:\/\/docs.sensu.io\/sensu-go\/latest\/files\/backend.yml -o \/etc\/sensu\/backend.yml<\/code><\/pre>\n\n\n\n

The sample configuration is highly commented;<\/p>\n\n\n\n

cat \/etc\/sensu\/backend.yml<\/code><\/pre>\n\n\n\n
---\n# Sensu backend configuration\n\n\n##\n# backend configuration\n##\n#labels:\n#  example_key: \"example value\"\n#annotations:\n#  example\/key: \"example value\"\n#assets-burst-limit: 100\n#assets-rate-limit: 1.39\n#agent-rate-limit: 100\n#cache-dir: \"\/var\/cache\/sensu\/sensu-backend\"\n#config-file: \"\/etc\/sensu\/backend.yml\"\n#debug: false\n#deregistration-handler: \"example_handler\"\nlog-level: \"debug\" #available log levels: panic, fatal, error, warn, info, debug, trace\n#state-dir: \"\/var\/lib\/sensu\/sensu-backend\"\n#require-fips: false\n#require-openssl: false\n#eventd-buffer-size: 100\n#eventd-workers: 100\n#keepalived-buffer-size: 100\n#keepalived-workers: 100\n#pipelined-buffer-size: 100\n#pipelined-workers: 100\n\n\n##\n# api configuration\n##\n#api-listen-address: \"[::]:8080\" #listen on all IPv4 and IPv6 addresses\n#api-request-limit: 512000\n#api-url: \"http:\/\/localhost:8080\"\n\n\n##\n# tls configuration\n##\n#agent-auth-cert-file: \/path\/to\/tls\/backend-1.pem\n#agent-auth-crl-urls: http:\/\/localhost\/CARoot.crl\n#agent-auth-key-file: \/path\/to\/tls\/backend-1-key.pem\n#agent-auth-trusted-ca-file: \/path\/to\/tls\/ca.pem\n#agent-burst-limit: null\n#agent-host: \"[::]\" #listen on all IPv4 and IPv6 addresses\n#agent-port: 8081\n#agent-rate-limit: null\n#cert-file: \"\/path\/to\/tls\/backend-1.pem\"\n#insecure-skip-tls-verify: false\n#jwt-private-key-file: \/path\/to\/key\/private.pem\n#jwt-public-key-file: \/path\/to\/key\/public.pem\n#key-file: \"\/path\/to\/tls\/backend-1-key.pem\"\n#trusted-ca-file: \"\/path\/to\/tls\/ca.pem\"\n#dashboard-cert-file: \"\/path\/to\/tls\/separate-webui-cert.pem\"\n#dashboard-host: \"[::]\"\n#dashboard-key-file: \"\/path\/to\/tls\/separate-webui-key.pem\"\n#dashboard-port: 3000\n\n\n##\n# etcd datastore configuration\n##\n#etcd-advertise-client-urls:\n#  - http:\/\/localhost:2378\n#  - http:\/\/localhost:2379\n#etcd-cert-file: \"\/path\/to\/tls\/backend-1.pem\"\n#etcd-cipher-suites:\n#  - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384\n#  - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384\n#  - TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256\n#  - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256\n#  - TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305\n#  - TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305\n#etcd-client-cert-auth: false\n#etcd-client-urls:\n#  - https:\/\/10.0.0.1:2379\n#  - https:\/\/10.1.0.1:2379\n#etcd-discovery:\n#  - https:\/\/discovery.etcd.io\/3e86b59982e49066c5d813af1c2e2579cbf573de\n#etcd-discovery-srv:\n#  - example.org\n#etcd-initial-advertise-peer-urls:\n#  - https:\/\/10.0.0.1:2380\n#  - https:\/\/10.1.0.1:2380\n#etcd-initial-cluster: \"backend-0=https:\/\/10.0.0.1:2380,backend-1=https:\/\/10.1.0.1:2380,backend-2=https:\/\/10.2.0.1:2380\"\n#etcd-initial-cluster-state: \"new\"\n#etcd-initial-cluster-token: \"unique_token_for_this_cluster\"\n#etcd-key-file: \"\/path\/to\/tls\/backend-1-key.pem\"\n#etcd-listen-client-urls:\n#  - https:\/\/10.0.0.1:2379\n#  - https:\/\/10.1.0.1:2379\n#etcd-listen-peer-urls:\n#  - https:\/\/10.0.0.1:2380\n#  - https:\/\/10.1.0.1:2380\n#etcd-name: \"backend-0\"\n#etcd-peer-cert-file: \"\/path\/to\/tls\/backend-1.pem\"\n#etcd-peer-client-cert-auth: false\n#etcd-peer-key-file: \"\/path\/to\/tls\/backend-1-key.pem\"\n#etcd-peer-trusted-ca-file: \".\/ca.pem\"\n#etcd-trusted-ca-file: \".\/ca.pem\"\n#no-embed-etcd: false\n#etcd-election-timeout: 3000\n#etcd-heartbeat-interval: 300\n#etcd-max-request-bytes: 1572864\n#etcd-quota-backend-bytes: 4294967296\n<\/code><\/pre>\n\n\n\n

You can then start and enable Sensu Go backend to run on system boot with the default configuration settings;<\/p>\n\n\n\n

sudo systemctl enable --now sensu-backend<\/code><\/pre>\n\n\n\n

Check the status of the Sensu Go backend command;<\/p>\n\n\n\n

systemctl status sensu-backend<\/code><\/pre>\n\n\n\n

Sample output;<\/p>\n\n\n\n

\u25cf sensu-backend.service - The Sensu Backend service.\n     Loaded: loaded (\/lib\/systemd\/system\/sensu-backend.service; enabled; vendor preset: enabled)\n     Active: active (running) since Fri 2022-05-06 20:56:19 UTC; 25s ago\n   Main PID: 10317 (sensu-backend)\n      Tasks: 9 (limit: 2241)\n     Memory: 29.2M\n        CPU: 872ms\n     CGroup: \/system.slice\/sensu-backend.service\n             \u2514\u250010317 \/usr\/sbin\/sensu-backend start -c \/etc\/sensu\/backend.yml\n\nMay 06 20:56:43 jellyfish sensu-backend[10317]: {\"component\":\"etcd\",\"level\":\"debug\",\"caller\":\"v3rpc\/interceptor.go:182\",\"msg\":\"request stats\",\"start time\":\"2022-05-06T20:5>\nMay 06 20:56:43 jellyfish sensu-backend[10317]: {\"component\":\"etcd\",\"level\":\"debug\",\"caller\":\"v3rpc\/lease.go:118\",\"msg\":\"failed to receive lease keepalive request from gRP>\nMay 06 20:56:43 jellyfish sensu-backend[10317]: {\"cache_version\":\"v1\",\"component\":\"cache\",\"level\":\"debug\",\"msg\":\"rebuilding the cache for resource type *v2.Silenced\",\"time>\nMay 06 20:56:43 jellyfish sensu-backend[10317]: {\"component\":\"etcd\",\"level\":\"debug\",\"caller\":\"v3rpc\/interceptor.go:182\",\"msg\":\"request stats\",\"start time\":\"2022-05-06T20:5>\nMay 06 20:56:43 jellyfish sensu-backend[10317]: {\"cache_version\":\"v2\",\"component\":\"cache\",\"level\":\"debug\",\"msg\":\"rebuilding the cache for resource type *v3.EntityConfig\",\">\nMay 06 20:56:43 jellyfish sensu-backend[10317]: {\"component\":\"etcd\",\"level\":\"debug\",\"caller\":\"v3rpc\/interceptor.go:182\",\"msg\":\"request stats\",\"start time\":\"2022-05-06T20:5>\nMay 06 20:56:43 jellyfish sensu-backend[10317]: {\"cache_version\":\"v1\",\"component\":\"cache\",\"level\":\"debug\",\"msg\":\"rebuilding the cache for resource type *v2.Namespace\",\"tim>\nMay 06 20:56:43 jellyfish sensu-backend[10317]: {\"component\":\"etcd\",\"level\":\"debug\",\"caller\":\"v3rpc\/interceptor.go:182\",\"msg\":\"request stats\",\"start time\":\"2022-05-06T20:5>\nMay 06 20:56:44 jellyfish sensu-backend[10317]: {\"cache_version\":\"v2\",\"component\":\"cache\",\"level\":\"debug\",\"msg\":\"rebuilding the cache for resource type *v3.EntityConfig\",\">\nMay 06 20:56:44 jellyfish sensu-backend[10317]: {\"component\":\"etcd\",\"level\":\"debug\",\"caller\":\"v3rpc\/interceptor.go:182\",\"msg\":\"request stats\",\"start time\":\"2022-05-06T20:\n<\/code><\/pre>\n\n\n\n

Check the status of the cluster;<\/p>\n\n\n\n

curl -s http:\/\/127.0.0.1:8080\/health | grep -oE '\"Healthy\":.*}]'<\/code><\/pre>\n\n\n\n

If the output contains “Healthy\":true<\/code><\/strong> then your cluster is fine.<\/p>\n\n\n\n

Create Sensu Administrator Account<\/h3>\n\n\n\n

Next, run the Sensu initialization command (sensu-backend init<\/strong><\/code>) below to create Sensu administrator account username and password.<\/p>\n\n\n\n

The basic usage of the sensu-backend init<\/strong> command can be checked on the help information;<\/p>\n\n\n\n

sensu-backend init --help<\/code><\/pre>\n\n\n\n
initialize a new sensu installation\n\nUsage:\n  sensu-backend init [flags]\n\nGeneral Flags:\n      --cluster-admin-api-key string    cluster admin API key\n      --cluster-admin-password string   cluster admin password\n      --cluster-admin-username string   cluster admin username\n  -c, --config-file string              path to sensu-backend config file (default \"\/etc\/sensu\/backend.yml\")\n  -h, --help                            help for init\n      --ignore-already-initialized      exit 0 if the cluster has already been initialized\n      --interactive                     interactive mode\n      --timeout string                  duration to wait before a connection attempt to etcd is considered failed (must be >= 1s) (default \"5s\")\n      --wait                            continuously retry to establish a connection to etcd until it is successful\n\nStore Flags:\n      --etcd-advertise-client-urls strings   list of this member's client URLs to advertise to clients (default [http:\/\/localhost:2379])\n      --etcd-cert-file string                path to the client server TLS cert file\n      --etcd-cipher-suites strings           list of ciphers to use for etcd TLS configuration\n      --etcd-client-cert-auth                enable client cert authentication\n      --etcd-client-log-level string         etcd client logging level [panic, fatal, error, warn, info, debug] (default \"error\")\n      --etcd-client-urls string              client URLs to use when operating as an etcd client\n      --etcd-key-file string                 path to the client server TLS key file\n      --etcd-max-request-bytes uint          maximum etcd request size in bytes (use with caution) (default 1572864)\n      --etcd-trusted-ca-file string          path to the client server TLS trusted CA cert file\n<\/code><\/pre>\n\n\n\n

Thus, to create Sensu admin account username and password, you have to pass the following options to the sensu-backend init<\/code><\/strong> command.<\/p>\n\n\n\n

--cluster-admin-username <username> --cluster-admin-password <password><\/code><\/pre>\n\n\n\n

You can also use the following variables for both username and password respectively;<\/p>\n\n\n\n

SENSU_BACKEND_CLUSTER_ADMIN_USERNAME=<username>\nSENSU_BACKEND_CLUSTER_ADMIN_PASSWORD=<password><\/code><\/pre>\n\n\n\n

For example, to create the account using the variables, first disable bash history;<\/p>\n\n\n\n

set +o history<\/code><\/pre>\n\n\n\n

Set the username\/password variables;<\/p>\n\n\n\n

export SENSU_BACKEND_CLUSTER_ADMIN_USERNAME=sensuadmin<\/strong>\nexport SENSU_BACKEND_CLUSTER_ADMIN_PASSWORD=password<\/strong><\/code><\/pre>\n\n\n\n

Initialize Sensu instance<\/p>\n\n\n\n

sensu-backend init<\/code><\/pre>\n\n\n\n

Sample output;<\/p>\n\n\n\n

{\"component\":\"cmd\",\"level\":\"info\",\"msg\":\"attempting to connect to etcd server: http:\/\/localhost:2379\",\"time\":\"2022-05-06T21:05:46Z\"}\n{\"component\":\"backend.seeds\",\"level\":\"info\",\"msg\":\"seeding etcd store with initial data\",\"time\":\"2022-05-06T21:05:46Z\"}\n{\"component\":\"store\",\"level\":\"warning\",\"msg\":\"migrating etcd database to a new version\",\"time\":\"2022-05-06T21:05:48Z\"}\n{\"component\":\"store\",\"database_version\":1,\"level\":\"info\",\"msg\":\"successfully upgraded database\",\"time\":\"2022-05-06T21:05:48Z\"}\n{\"component\":\"store\",\"database_version\":2,\"level\":\"info\",\"msg\":\"successfully upgraded database\",\"time\":\"2022-05-06T21:05:49Z\"}\n{\"component\":\"store\",\"level\":\"warning\",\"msg\":\"migrating enterprise etcd database to a new version\",\"time\":\"2022-05-06T21:05:49Z\"}\n{\"component\":\"store\",\"database_version\":1,\"level\":\"info\",\"msg\":\"successfully upgraded database\",\"time\":\"2022-05-06T21:05:49Z\"}\n{\"component\":\"store\",\"database_version\":2,\"level\":\"info\",\"msg\":\"successfully upgraded database\",\"time\":\"2022-05-06T21:05:49Z\"}\n<\/code><\/pre>\n\n\n\n

Enable the bash history;<\/p>\n\n\n\n

set -o history<\/code><\/pre>\n\n\n\n

You can always verify the user credentials or reset the user password using the sensuctl<\/code><\/strong> command.<\/p>\n\n\n\n

Before you can use Sensu CLI command, you need to initialize sensuctl configuration<\/p>\n\n\n\n

sensuctl configure<\/code><\/pre>\n\n\n\n

Go through the prompts accordingly.<\/p>\n\n\n\n

Sample output;<\/p>\n\n\n\n

? Authentication method: username\/password\n? Sensu Backend API URL: http:\/\/127.0.0.1:8080\n? Namespace: default\n? Preferred output format: tabular\n? Username: sensuadmin\n? Password: ********\n<\/code><\/pre>\n\n\n\n

You can also run the command in non-interactive mode;<\/p>\n\n\n\n

sensuctl configure -n \\\n--username 'YOUR_USERNAME' \\\n--password 'YOUR_PASSWORD' \\\n--namespace default \\\n--url 'http:\/\/127.0.0.1:8080'\n<\/code><\/pre>\n\n\n\n

Change admin password;<\/p>\n\n\n\n

sensuctl user change-password --interactive<\/code><\/pre>\n\n\n\n

Reset user’s forgotten password;<\/p>\n\n\n\n

sensuctl user reset-password USERNAME --interactive<\/code><\/pre>\n\n\n\n

Accessing Sensu Go Web UI<\/h3>\n\n\n\n

The Sensu Go web UI service listens on port<\/a> 3000\/tcp by default.<\/p>\n\n\n\n

sudo ss -altnp | grep sensu<\/code><\/pre>\n\n\n\n
LISTEN 0      4096       127.0.0.1:2379      0.0.0.0:*    users:((\"sensu-backend\",pid=3462,fd=8)) \nLISTEN 0      4096       127.0.0.1:2380      0.0.0.0:*    users:((\"sensu-backend\",pid=3462,fd=7)) \nLISTEN 0      4096               *:8080            *:*    users:((\"sensu-backend\",pid=3462,fd=18))\nLISTEN 0      4096               *:8081            *:*    users:((\"sensu-backend\",pid=3462,fd=19))\nLISTEN 0      4096               *:3000            *:*    users:((\"sensu-backend\",pid=3462,fd=20))\n<\/code><\/pre>\n\n\n\n

If the Firewall is running, open this port to allow external access.<\/p>\n\n\n\n

sudo ufw allow 3000\/tcp<\/code><\/pre>\n\n\n\n

The access your Sensu Go Web UI using the address http:\/\/server-address-or-IP:3000<\/code><\/strong>.<\/p>\n\n\n\n

\"install<\/figure><\/div><\/a><\/div>\n\n\n\n

Login using the credentials created above.<\/p>\n\n\n\n

Sensu Dashboard<\/p>\n\n\n\n

\"install<\/figure><\/a><\/div>\n\n\n\n

Sensu is now running on Ubuntu 22.04<\/p>\n\n\n\n

In our next guide, we will learn how to install Sensu agents and start monitoring your end points.<\/p>\n\n\n\n

Install Sensu Agent on Ubuntu\/Debian<\/a><\/p>\n\n\n\n

Install Sensu Agent on Windows systems<\/a><\/p>\n\n\n\n

Reference<\/h3>\n\n\n\n

Install Sensu<\/a><\/p>\n\n\n\n

Other Tutorials<\/h3>\n\n\n\n

Monitor Process Creation Events on Windows Systems using Wazuh and ELK stack<\/a><\/p>\n\n\n\n

Install ELK Stack 8.x on Ubuntu<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

In this tutorial to learn how to install Sensu Go on Ubuntu 22.04. Sensu is an opensource infrastructure and application monitoring tool. Install Sensu Go<\/p>\n","protected":false},"author":1,"featured_media":12590,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[72,121],"tags":[5048,5046,5051,5049,5047,5050,5052],"class_list":["post-12595","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-monitoring","category-howtos","tag-install-sensu-go","tag-install-sensu-ubuntu-22-04","tag-install-sentu","tag-sensu-backend","tag-sensu-go-ubuntu-22-04","tag-sensuctl","tag-ubuntu-22-04-sensu","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/12595"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=12595"}],"version-history":[{"count":4,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/12595\/revisions"}],"predecessor-version":[{"id":20541,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/12595\/revisions\/20541"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/12590"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=12595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=12595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=12595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}