Perform the following steps:
- Log in to the Prometheus guest instance:
vagrant ssh prometheus
- Inside the guest instance, drop to the root:
sudo -i
- Add all the guests' addresses to the instance host's file:
cat <<EOF >/etc/hosts
127.0.0.1 localhost
192.168.42.10 prometheus.prom.inet prometheus
192.168.42.11 grafana.prom.inet grafana
192.168.42.12 alertmanager.prom.inet alertmanager
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF
- Create a new system user:
useradd --system prometheus
- Go into /tmp and download the Prometheus archive:
cd /tmp
curl -sLO "https://github.com/prometheus/prometheus/releases/download/v2.9.2/prometheus-2.9.2.linux-amd64.tar.gz"
- Uncompress the archive:
tar zxvf prometheus-2.9.2.linux-amd64.tar.gz
- Place every file in its correct location:
install -m 0644 -D -t /usr/share/prometheus/consoles prometheus-2.9.2.linux-amd64/consoles/*
install -m 0644 -D -t /usr/share/prometheus/console_libraries prometheus-2.9.2.linux-amd64/console_libraries/*
install -m 0755 prometheus-2.9.2.linux-amd64/prometheus prometheus-2.9.2.linux-amd64/promtool /usr/bin/
install -d -o prometheus -g prometheus /var/lib/prometheus
install -m 0644 -D /vagrant/chapter03/configs/prometheus/prometheus.yml /etc/prometheus/prometheus.yml
install -m 0644 -D /vagrant/chapter03/configs/prometheus/first_rules.yml /etc/prometheus/first_rules.yml
- Add a systemd unit file for the Prometheus service:
install -m 0644 /vagrant/chapter03/configs/prometheus/prometheus.service /etc/systemd/system/
systemctl daemon-reload
- Enable and start the Prometheus service:
systemctl enable prometheus
systemctl start prometheus
You should now have the Prometheus HTTP endpoint available on your host.
- Exit the root account and then the Vagrant user account:
exit
exit