prometheus
prometheus是一套开源的监控与报警与时间序列数据库的组合。
grafana
grafana是一个跨平台的开源的度量分析和可视化工具,可以通过将采集的数据查询然后可视化的展示,并及时通知。
node_exporter
node_exporter是采集器,负责将采集的数据存储到prometheus数据库,然后grafana取promethues数据库的数据进行展示。
安装包:可以去官网下载离线安装包https://prometheus.io/download/
https://grafana.com/
如果觉得官网下载很慢,可以在csdn里面下载,此次安装包下载 https://download.csdn.net/download/weixin_45548465/87383302
使用ubuntu1804部署 192.168.190.194
prometheus的安装
wget https://github.com/prometheus/prometheus/releases/download/v2.41.0/prometheus-2.41.0.linux-amd64.tar.gz
tar -xvf prometheus-2.41.0.linux-amd64.tar.gz
mv prometheus-2.41.0.linux-amd64 /usr/local/prometheus
cd /usr/local/prometheus
cp prometheus /usr/local/bin/
cp promtool /usr/local/bin/
mkdir -p /etc/prometheus && mkdir -p /var/lib/prometheus
cp -p prometheus.yml /etc/prometheus/
vi /usr/lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus: the monitoring system
Documentation=http://prometheus.io/docs/
[Service]
ExecStart=/usr/local/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus
Restart=always
StartLimitInterval=0
RestartSec=10
[Install]
WantedBy=multi-user.target
systemctl daemon-reload && systemctl start prometheus && systemctl enable prometheus
通过网址访问 http:ip:9090
被监控主机安装node_exporter 192.168.190.39
wget https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz
tar xvf node_exporter-1.5.0.linux-amd64.tar.gz
mv node_exporter-1.5.0.linux-amd64/node_exporter /usr/local/bin/
vi /etc/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target
[Service]
ExecStart=/usr/local/bin/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
systemctl start node_exporter && systemctl enable node_exporter
配置prometheus server端可以拉取node信息 在文件最后添加内容 注意格式
vim /etc/prometheus/prometheus.yml
- job_name: "node"
static_configs:
- targets: ["192.168.190.39:9100"]
systemctl restart prometheus
web端刷新,可以看到增加了一台监控的信息
grafana安装 192.168.190.194
sudo apt-get install -y adduser libfontconfig1
wget https://dl.grafana.com/enterprise/release/grafana-enterprise_9.3.2_amd64.deb
sudo dpkg -i grafana-enterprise_9.3.2_amd64.deb
systemctl start grafana-server && systemctl enable grafana-server
web登录 http://ip:3000 账户密码都是admin
添加数据源
设置数据源,名称、类型、ip和端口 (填写)
添加图形
可以去官网下载模板 https://grafana.com/grafana/dashboards
导入模板
import 后即可看到当前服务器监控信息
参考文档:https://www.cnblogs.com/hurric/p/16363155.html
https://zhuanlan.zhihu.com/p/443034743
https://note.youdao.com/ynoteshare/index.html?id=65c974d251958a70c75f9840d91467f9&type=note&_time=1673745353585