Prometheus使用node-exporter监控服务器运行情况
作用
node_exporter 是一个用于收集主机指标的 Prometheus exporter。
1.下载node-exporter
下载地址:https://github.com/prometheus/prometheus/releases
2.上传到服务器并解压
tar -zxvf xxx.tar.gz
3.启动node-exporter
#--web.listen-address=:1801注意冒号不能省略,是localhost:1801的缩写
nohup ./node_exporter --web.listen-address=:1801 >start.log &
4.访问页面查看指标
访问http://localhost:1801/metrics,能看到一堆指标,说明启动成功。
5.配置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.
alerting:
alertmanagers:
- static_configs:
- targets:
rule_files:
scrape_configs:
- job_name: "fast-boot"
static_configs:
- targets: ["192.43.149.7:1888"]
labels:
namespace: "fast-boot"
service: "fast-boot"
#node-exporter的配置
- targets: ["192.43.149.7:1801"]
labels:
#下面的标签可以自定义
namespace: "fast-boot"
service: "fast-boot"
6.配置完成后,重启prometheus
nohup ./prometheus >start.log &
如下图,说明配置成功了
7.配置grafana面板
点击dashboard,点击import,输入模板号:8919或者11074,二选一即可,个人喜欢11074。
8919模板地址:https://grafana.com/grafana/dashboards/8919-1-node-exporter-for-prometheus-dashboard-cn-0413-consulmanager/
11074模板地址:https://grafana.com/grafana/dashboards/11074-node-exporter-for-prometheus-dashboard-en-v20201010/
至此,大功告成,保存即可,细节可以自己慢慢调。