Berikut adalah cara membuat Monitoring Server menggunakan Node Exporter , Prometheus dan Grafana di Linux.
Install Node Exporter
- Link Download Node Exporter
- buka link : https://prometheus.io/download#node_exporter
- kemudian pilih yang berformat tar dan pilih sesuai sistem operasi , contohnya linux/amd64
1
wget url
Extract Node Exporter
1
tar xvfz node_exporter-*.*-amd64.tar.gz
Copy Node Exporter
1
2
3cd node_exporter
cp node_exporter /usr/local/bin/Buat Service Node Exporter dengan cara menjalankan perintah dibawah ini.
1
sudo nano /etc/systemd/system/node_exporter.service
isi dengan code berikut :
1
2
3
4
5
6
7
8
9
10
11
12
13[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=root
Group=root
Type=simple
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
Jalankan Service Node Exporter
1
sudo systemctl start node_exporter
Aktifkan service node_exporter agar tetap jalan ketika di restart
1
sudo systemctl enable node_exporter
Buka Service menggunakan browser
- ketik url dengan ip address server , contohnya http://localhost:9100
- port node_exporter : 9100
- Tampilan node_exporter didalam browser
Install Prometheus ( docker )
Pull docker image
1
sudo docker pull prom/prometheus
Jalankan docker container
1
sudo docker run -d --name prometheus --restart always --net host /etc/localtime:/etc/localtime:ro prom/prometheus
config prometheus.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32# my global config
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_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["localhost:9090"]
- job_name: "node_exporter"
static_configs:
- targets: ["localhost:9100"]copy config diatas menggunakan perintah berikut di dalam terminal
1
sudo docker exec -ti prometheus vi /etc/prometheus/prometheus.yml
hapus semua isinya dan ganti dengan config diatas
- Buka service menggunakan browser
- port default promotheus : 9090
- url : http://localhost:9090
- Buka menu targets maka dan harusnya akan muncul 2 targets yaitu node_exporter dan promotheus seperti ini.
Install Grafana ( docker )
Pull docker image
1
sudo docker pull grafana/grafana
Jalankan docker container
1
sudo docker run -d --name grafana --net host grafana/grafana
Buka service menggunakan browser
- grafana default port : 3000
- url : http://localhost:3000
- user : admin
- pass : admin
- Aktifkan Data Source di Configuration Datasource dan Pilih promotheus
- Masukan url promotheus
- Pilih Service Promotheus
- Pilih menu dashboard kemudian pilih Import
- Import tampilan Dashboard dengan ID 11074
- Buka dashboard yang sudah di import tadi dan akan tampil seperti ini.