
Monitoring server menggunakan Prometheus dan Grafana
27 July, 2024
0
0
0
Contributors
- Download Prometheus dan Node Exporter
- Download Prometheus
cd && wget https://github.com/prometheus/prometheus/releases/download/v2.53.1/prometheus-2.53.1.linux-amd64.tar.gz
https://prometheus.io/download/
- Download Node Exporter
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz
- Unzip Prometheus and Node Exporter
tar xvf prometheus-2.53.1.linux-amd64.tar.gz
tar xvf node_exporter-1.8.2.linux-amd64.tar.gz
- Jalankan Prometheus menggunakan systemd/background proses
- Create group and user prometheus
sudo groupadd --system prometheus
sudo useradd --system -s /sbin/nologin -g prometheus prometheus
- Pindahkan file prometheus
sudo mv prometheus promtool /usr/local/bin
sudo mv console_libraries/ consoles/ prometheus.yml /etc/prometheus/
- config prometheus
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus
- config prometheus.yml
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "node-exporter"
static_configs:
- targets: ["localhost:9100"]
- jalankan prometheus di systemd
sudo nano /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
- Check status prometheus service
sudo systemctl status prometheus
- Jalankan
sudo systemctl enable --now prometheus.service
- check port
sudo lsof -n -i | grep prometheus
- Config Node Exporter
sudo mv node_exporter /usr/local/bin
- tambahkan systemd
sudo nano /etc/systemd/system/node-exporter.service
[Unit]
Description=Node Exporter
[Service]
Restart=always
User=prometheus
Type=simple
ExecStart=/usr/local/bin/node_exporter
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=20s
SendSIGKILL=no
[Install]
WantedBy=multi-user.target
- check status
sudo systemctl status node-exporter.service
- Jalankan
sudo systemctl enable --now node-exporter.service
- Check port
sudo lsof -n -i | grep node
- Install Grafana
doc link
https://grafana.com/docs/grafana/latest/setup-grafana/installation/debian/
- Menambahkan data source
Buka menu Connection>Data Sources lalu pilih Prometheus
- Menambahkan Graph Node Exporter
https://grafana.com/grafana/dashboards/1860-node-exporter-full/