-
Notifications
You must be signed in to change notification settings - Fork 16
Lab_00| Prometheus Setup
In this section of Lab we'll be starting with :
* Installing Prometheus
* Service Start of Prometheus
* A Linux VM or Machine
* A non-root sudo user, preferably one named prometheus
cd /etc/Use wget to download the latest build of the Prometheus server and time-series database from GitHub and Use tar to extract prometheus-2.2.1.linux-amd64.tar.gz:
wget https://github.com/prometheus/prometheus/releases/download/v2.2.1/prometheus-2.2.1.linux-amd64.tar.gz
tar -xvzf prometheus-2.2.1.linux-amd64.tar.gz
rm -rf prometheus-2.2.1.linux-amd64.tar.gz
mv prometheus-2.2.1.linux-amd64/ prometheusPrometheus needs a directory to store its data. We will create /var/lib/prometheus
mkdir /var/lib/prometheusPreferred directory to put third party binaries on Linux is /usr/local/bin/ since it is in $PATH by default and it doesn't interfere with system binaries.
cp prometheus promtool /usr/local/bin/Verify the installation by typing in the following command:
prometheus --versiongroupadd --system prometheus
useradd -s /sbin/nologin -r -g prometheus prometheusThe ownership of Prometheus files and data should be its user and group.
chown -R prometheus:prometheus /etc/prometheus/ /var/lib/prometheus/
chmod -R 775 /etc/prometheus/ /var/lib/prometheus/We need to create a Service unit file for managing Prometheus service. We will put the file under /etc/systemd/system directory. The name of the file has to end with .service
$ vi /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus systemd service unit
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=prometheus
Group=prometheus
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/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 \
--web.listen-address=0.0.0.0:9090
SyslogIdentifier=prometheus
Restart=always
[Install]
WantedBy=multi-user.targetStart and enable Prometheus service to start on boot.
systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus
systemctl status prometheusOnce it starts, use a browser to view Prometheus web interface, which is available at http://your_server_ip:9090