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 di:
https://domain-anda/grafana/
Login default:
| Field | Nilai |
|---|---|
| Username | admin |
| Password | admin |
Ganti password default segera setelah login pertama.
Cara Membaca Dashboard
Node Exporter (Sistem)
Metrics utama yang perlu diperhatikan:
- 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 I/O — throughput read/write. Spike tinggi saat restore database atau awal ujian adalah normal.
- Network Traffic — bandwidth in/out. Berguna untuk deteksi DDoS atau traffic abnormal.
- Load Average — rata-rata antrian proses. Angka di bawah jumlah CPU core = sehat.
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_connectionsdi konfigurasi. - Slow Queries — query yang lambat. 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)
- Active Connections — koneksi aktif saat ini. Bandingkan dengan
worker_connectionsdi nginx.conf. - Request Rate — request per detik. Spike = banyak peserta akses bersamaan.
- Accepted/Handled — jika
accepted>handled, ada koneksi yang di-drop. - Reading/Writing/Waiting — breakdown status koneksi.
waitingtinggi = keep-alive connections (normal).
PHP-FPM Exporter (PHP)
- Active Processes — proses PHP yang sedang handle request. Mendekati
pm.max_children= perlu tambah. - Listen Queue — antrian request menunggu proses PHP kosong. Di atas 0 terus-menerus = bottleneck.
- Max Children Reached — berapa kali limit proses tercapai. Angka naik = perlu naikkan
pm.max_children. - Request Duration — waktu rata-rata per request. Di atas 1 detik = investigasi query atau kode.
Skenario Saat Ujian
Sebelum Ujian
- Buka Grafana, cek semua panel hijau / normal
- Pastikan tidak ada error di Prometheus targets (
https://domain/grafana/→ Connections → Data sources) - 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 reverse proxy:
nginx -t
grep -A 10 "location /grafana" /etc/nginx/sites-available/ujian
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, dan konfigurasi proxy akan dihapus.