Skip to content

Instantly share code, notes, and snippets.

@Trailingslashes
Created June 10, 2019 01:32
Show Gist options
  • Save Trailingslashes/2c67dfcbc067431abc87f5f8a2ddfb70 to your computer and use it in GitHub Desktop.
Save Trailingslashes/2c67dfcbc067431abc87f5f8a2ddfb70 to your computer and use it in GitHub Desktop.
Prometheus Setup
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
useradd --no-create-home --shell /bin/false prometheus
mkdir /etc/prometheus
mkdir /var/lib/prometheus
chown prometheus:prometheus /var/lib/prometheus
cd /tmp/
wget https://github.com/prometheus/prometheus/releases/download/v2.10.0/prometheus-2.10.0.linux-amd64.tar.gz
tar -xvf prometheus-2.10.0.linux-amd64.tar.gz
mv console* /etc/prometheus
mv prometheus.yml /etc/prometheus
chown -R prometheus:prometheus /etc/prometheus
mv prometheus /usr/local/bin/
mv promtool /usr/local/bin/
chown prometheus:prometheus /usr/local/bin/prometheus
chown prometheus:prometheus /usr/local/bin/promtool
: << --COMMENT BLOCK--
sudo vim /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
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
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus
--END OF COMMENT BLOCK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment