Prometheus
node_exporter
package
1
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz
prepare user and directory
1
2
3
4
5
6
7sudo groupadd -f dingofs
sudo useradd -g dingofs dingofs
sudo mkdir /etc/node_exporter
sudo chown dingofs:dingofs /etc/node_exporter
sudo cp /path/to/node_exporter-files/node_exporter /usr/bin/
sudo chown dingofs:dingofs /usr/bin/node_exporterconfig system service
1
2sudo vi /usr/lib/systemd/system/node_exporter.service
sudo chmod 664 /usr/lib/systemd/system/node_exporter.service1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16[Unit]
Description=Node Exporter
Documentation=https://prometheus.io/docs/guides/node-exporter/
Wants=network-online.target
After=network-online.target
[Service]
User=dingofs
Group=dingofs
Type=simple
Restart=on-failure
ExecStart=/usr/bin/node_exporter \
--web.listen-address=:19100
[Install]
WantedBy=multi-user.targetstart system service
1
2
3
4sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl status node_exporter
sudo systemctl enable node_exporter.service # Configure node_exporter to start at boot
prometheus server
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
29global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
evaluation_interval: 15s # Evaluate rules every 15 seconds.
# Attach these extra labels to all timeseries collected by this Prometheus instance.
external_labels:
monitor: 'codelab-monitor'
#rule_files:
#- 'prometheus.rules.yml'
scrape_configs:
- job_name: 'prometheus'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
static_configs:
- targets: ['172.20.7.232:19090']
- job_name: 'node'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
static_configs:
- targets: ['172.20.7.232:19100','172.20.7.233:19100','172.20.7.234:19100']
labels:
group: 'metric1'docker container
1 | Create persistent volume for your data |
Grafana
deploy container
1
2
3
4
5
6
7
8
9
10
11
12
13create a persistent volume for your data
docker volume create grafana-storage
verify that the volume was created correctly
you should see some JSON output
docker volume inspect grafana-storage
start grafana
docker run -d -p 13000:3000 --name=grafana \
--volume grafana-storage:/var/lib/grafana \
grafana/grafana
web login
admin/admin
dashboard
https://grafana.com/grafana/dashboards/
just import from existed dashboard json
enjoy it