Panduan Monitoring

Monitoring stack untuk memantau performa dan kesehatan server ujian secara real-time.

Instalasi

examtool setup-monitoring

Komponen yang diinstall:

Komponen Port Fungsi
Prometheus 9090 Pengumpul metrics
Grafana 3000 Dashboard visualisasi
Node Exporter 9100 Metrics sistem (CPU, RAM, disk, network)
MariaDB Exporter 9104 Metrics database (query, connections, replication)
Memcached Exporter 9150 Metrics cache (hit ratio, memory, evictions)
Nginx Exporter 9113 Metrics web server (request rate, connections)
PHP-FPM Exporter 9253 Metrics PHP (active processes, request duration)

Semua exporter hanya bind ke 127.0.0.1 — tidak bisa diakses dari luar server.

Akses Grafana

Setelah install, Grafana tersedia langsung di:

http://IP_SERVER:3000

Port 3000 otomatis dibuka di firewall (UFW) saat setup monitoring.

Login default:

Field Nilai
Username admin
Password admin

Ganti password default segera setelah login pertama.

Dashboard Otomatis

Saat setup-monitoring dijalankan, examtool otomatis membuat:

  • Datasource Prometheus (auto-provisioned via file)
  • Dashboard "System Dashboard" dengan panel:
    • System: CPU usage, memory usage, disk usage, load average, network I/O
    • Nginx: requests/sec, active connections, connection states
    • PHP-FPM: active/idle processes, listen queue, slow requests
    • MariaDB: queries/sec, connections, slow queries
    • Memcached: hit ratio, memory usage, evictions, current items
  • Dashboard "Node Exporter Full" — dashboard detail dari Grafana.com (ID: 1860)

Dashboard auto-refresh setiap 30 detik.

Cara Membaca Dashboard

System (Node Exporter)

  • CPU Usage — persentase penggunaan CPU. Di atas 80% saat ujian = normal untuk tier SMALL. Di atas 90% terus-menerus = perlu upgrade.
  • Memory Usage — RAM terpakai. Sisakan minimal 500MB free untuk buffer/cache.
  • Disk Usage — persentase pemakaian disk root filesystem.
  • Load Average — rata-rata antrian proses 1 menit. Angka di bawah jumlah CPU core = sehat.
  • Network I/O — bandwidth receive/transmit per interface.

MariaDB Exporter (Database)

  • Queries per Second — jumlah query per detik. Naik drastis saat ujian dimulai, stabil setelahnya.
  • Connections — koneksi aktif ke database. Bandingkan dengan max_connections di konfigurasi.
  • Slow Queries — query yang lambat (> 2 detik). Jika meningkat, cek indeks tabel.
  • Buffer Pool Hit Ratio — seharusnya di atas 99%. Di bawah 95% = InnoDB buffer pool terlalu kecil.

Memcached Exporter (Cache)

  • Hit Ratio — persentase cache hit. Di atas 80% = bagus. Di bawah 50% = cache tidak efektif atau baru di-restart.
  • Evictions — item yang dibuang karena memori penuh. Angka tinggi = perlu tambah alokasi memori Memcached.
  • Current Items — jumlah item tersimpan di cache.
  • Memory Usage — pemakaian memori vs limit yang dikonfigurasi.

Nginx Exporter (Web Server)

  • Requests/sec — request per detik. Spike = banyak peserta akses bersamaan.
  • Active Connections — koneksi aktif saat ini.
  • Connection States — breakdown reading/writing/waiting. waiting tinggi = keep-alive connections (normal).

PHP-FPM Exporter (PHP)

  • Active/Idle Processes — proses PHP aktif vs idle. Active mendekati pm.max_children = perlu tambah.
  • Listen Queue — antrian request menunggu proses PHP kosong. Di atas 0 terus-menerus = bottleneck.
  • Slow Requests — request yang lambat. Angka naik = investigasi query atau kode.

Skenario Saat Ujian

Sebelum Ujian

  1. Buka Grafana di http://IP_SERVER:3000
  2. Cek dashboard "System Dashboard" — semua panel hijau/normal
  3. Catat baseline CPU, RAM, connections saat idle

Selama Ujian

Pantau secara berkala:

  • CPU tidak terus di atas 90%
  • Listen Queue PHP-FPM tetap 0 atau mendekati 0
  • MariaDB Connections tidak mendekati limit
  • Memcached Hit Ratio tetap di atas 70%

Setelah Ujian

  • Cek Slow Queries di panel MariaDB
  • Review error rate di Nginx
  • Simpan screenshot dashboard untuk dokumentasi

Troubleshooting Monitoring

Exporter tidak muncul di Prometheus

Cek apakah service berjalan:

systemctl status node_exporter
systemctl status mysqld_exporter
systemctl status memcached_exporter
systemctl status nginx_exporter
systemctl status phpfpm_exporter

Test endpoint secara manual:

curl http://127.0.0.1:9100/metrics | head
curl http://127.0.0.1:9104/metrics | head
curl http://127.0.0.1:9150/metrics | head
curl http://127.0.0.1:9113/metrics | head
curl http://127.0.0.1:9253/metrics | head

Grafana tidak bisa diakses

systemctl status grafana-server
journalctl -u grafana-server --no-pager -n 20

# Cek firewall
ufw status | grep 3000

MariaDB Exporter gagal connect

# Cek kredensial
cat /etc/.mysqld_exporter.cnf

# Test koneksi manual
mysql -u exporter -p$(grep password /etc/.mysqld_exporter.cnf | cut -d= -f2) -e "SELECT 1"

PHP-FPM Exporter tidak dapat metrics

Pastikan pm.status_path aktif:

grep "pm.status_path" /etc/php/8.3/fpm/pool.d/ujian.conf

Jika belum ada, tambahkan:

echo 'pm.status_path = /status' >> /etc/php/8.3/fpm/pool.d/ujian.conf
systemctl reload php8.3-fpm

Nginx stub_status tidak tersedia

curl http://127.0.0.1:8080/stub_status

Jika gagal, cek file konfigurasi:

cat /etc/nginx/conf.d/stub_status.conf
nginx -t

Hapus Monitoring

Jika monitoring tidak lagi diperlukan:

examtool remove-monitoring --confirm

Semua komponen, service, user, provisioning config, dan dashboard akan dihapus. Port 3000 ditutup kembali di firewall.