The following will walk you through how to install and configure Prometheus. This should NOT be installed on a Couchbase node, but rather on a standalone server in the same network as your Couchbase cluster.
Download the Prometheus binary to the server that you will use for Prometheus.
wget \
https://github.com/prometheus/prometheus/releases/download/v2.24.0/prometheus-2.24.0.linux-amd64.tar.gzVisit the Prometheus downloads page for the latest version.
Create a Prometheus user, required directories, and make prometheus user as the owner of those directories.
sudo groupadd -f prometheus
sudo useradd -g prometheus --no-create-home --shell /bin/false prometheus
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus
sudo chown prometheus:prometheus /etc/prometheus
sudo chown prometheus:prometheus /var/lib/prometheusUntar and move the downloaded Prometheus binary
tar -xvf prometheus-2.24.0.linux-amd64.tar.gz
mv prometheus-2.24.0.linux-amd64 prometheus-filesCopy prometheus and promtool binary from prometheus-files folder to /usr/bin and change the ownership to prometheus user.
sudo cp prometheus-files/prometheus /usr/bin/
sudo cp prometheus-files/promtool /usr/bin/
sudo chown prometheus:prometheus /usr/bin/prometheus
sudo chown prometheus:prometheus /usr/bin/promtoolMove the prometheus.yml, consoles and console_libraries directories from prometheus-files to /etc/prometheus folder and change the ownership to prometheus user.
sudo cp -r prometheus-files/consoles /etc/prometheus
sudo cp -r prometheus-files/console_libraries /etc/prometheus
sudo cp prometheus-files/prometheus.yml /etc/prometheus/prometheus.yml
sudo chown -R prometheus:prometheus /etc/prometheus/consoles
sudo chown -R prometheus:prometheus /etc/prometheus/console_libraries
sudo chown prometheus:prometheus /etc/prometheus/prometheus.ymlCreate a prometheus service file.
sudo vi /usr/lib/systemd/system/prometheus.serviceAdd the following configuration and save the file
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/bin/prometheus \
--config.file /etc/prometheus/prometheus.yml \
--storage.tsdb.path /var/lib/prometheus/ \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries
[Install]
WantedBy=multi-user.targetsudo chmod 664 /usr/lib/systemd/system/prometheus.serviceNote: Prometheus is configured to use /var/lib/prometheus as it's tsdb storage location, ensure there is enough space available.
Reload the systemd service to register the prometheus service and start the prometheus service.
sudo systemctl daemon-reload
sudo systemctl start prometheusCheck the prometheus service status using the following command.
sudo systemctl status prometheusConfigure Prometheus to start at boot
sudo systemctl enable prometheus.serviceIf firewalld is enabled and running, add a rule for port 9090
sudo firewall-cmd --permanent --zone=public --add-port=9090/tcp
sudo firewall-cmd --reloadNow you will be able to access the prometheus UI on 9090 port of the prometheus server.
http://<prometheus-ip>:9090/graphYou should be able to see the following UI as shown below.
Remove the download and temporary files
rm -rf prometheus-2.24.0.linux-amd64.tar.gz prometheus-files