Created
April 13, 2022 04:43
-
-
Save olex0r/bc6ae4f63597884f8e19ffc76e9a4cad to your computer and use it in GitHub Desktop.
Draft: Prometheus + Grafana
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cd ~ | |
wget https://github.com/prometheus/prometheus/releases/download/v2.34.0/prometheus-2.34.0.linux-amd64.tar.gz | |
tar -xvf prometheus-2.34.0.linux-amd64.tar.gz | |
cd prometheus-2.34.0.linux-amd64 | |
sudo mkdir -p /etc/prometheus | |
sudo mkdir -p /var/lib/prometheus | |
sudo mv prometheus promtool /usr/local/bin/ | |
sudo mv consoles/ console_libraries/ /etc/prometheus/ | |
sudo mv prometheus.yml /etc/prometheus/prometheus.yml | |
sudo groupadd --system prometheus | |
sudo useradd -s /sbin/nologin --system -g prometheus prometheus | |
sudo chown -R prometheus:prometheus /etc/prometheus/ /var/lib/prometheus/ | |
sudo chmod -R 775 /etc/prometheus/ /var/lib/prometheus/ | |
sudo vim /etc/systemd/system/prometheus.service | |
[Unit] | |
Description=Prometheus | |
Wants=network-online.target | |
After=network-online.target | |
[Service] | |
User=prometheus | |
Group=prometheus | |
Restart=always | |
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 \ | |
--web.listen-address=0.0.0.0:9090 | |
[Install] | |
WantedBy=multi-user.target | |
sudo systemctl start prometheus | |
sudo systemctl enable prometheus | |
sudo ufw allow from 95.217.88.52 to any port 9090 | |
cd ~ | |
wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz | |
tar -xvf node_exporter-1.3.1.linux-amd64.tar.gz | |
cd node_exporter-1.3.1.linux-amd64 | |
sudo mv -v node_exporter /usr/local/bin/ | |
sudo chown root:root /usr/local/bin/node_exporter | |
sudo vim /etc/systemd/system/node-exporter.service | |
[Unit] | |
Description=Prometheus exporter for machine metrics | |
[Service] | |
Restart=always | |
User=prometheus | |
ExecStart=/usr/local/bin/node_exporter | |
ExecReload=/bin/kill -HUP $MAINPID | |
TimeoutStopSec=20s | |
SendSIGKILL=no | |
[Install] | |
WantedBy=multi-user.target | |
sudo systemctl daemon-reload | |
sudo systemctl start node-exporter.service | |
sudo systemctl enable node-exporter.service | |
sudo vim /etc/prometheus/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment