cover-img

Monitoring server menggunakan Prometheus dan Grafana

27 July, 2024

0

0

0

  1. 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
  1. 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
  1. 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
  1. 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
  1. 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/


0

0

0

Hajar Aswad

Jakarta Selatan, Indonesia

Full Stack Developer | Web Developer | Backend Developer

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2025. Showcase Creators Inc. All rights reserved.