Prometheus+grafana安装
Prometheus+grafana安装
Prometheus安装
操作系统:rocky8
将下载下来的压缩包上传至/usr/local
cd /usr/local
tar zxvf prometheus-2.37.0.linux-amd64.tar.gz
mv prometheus-2.37.0.linux-amd64 prometheus
查看版本
./prometheus --version
启动
./prometheus
以服务启动
vi /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus Monitoring System
Documentation=Prometheus Monitoring System
[Service]
ExecStart=/usr/local/prometheus/prometheus \
--config.file=/usr/local/prometheus/prometheus.yml \
--web.listen-address=:9090
[Install]
WantedBy=multi-user.target
启动服务
systemctl daemon-reload
systemctl enable prometheus
systemctl start prometheus
systemctl status prometheus
查看端口
netstat -tnlp
安装Node Exporter
上传文件至/usr/local
cd /usr/local
tar zxvf node_exporter-1.4.0-rc.0.linux-amd64.tar.gz
mv node_exporter-1.4.0-rc.0.linux-amd64 node_exporter
以服务启动
vi /etc/systemd/system/node_exporter.service
[Unit]
Description=https://prometheus.io
[Service]
Restart=on-failure
ExecStart=/usr/local/node_exporter/node_exporter
[Install]
WantedBy=multi-user.target
启动并设置为开机自动启动
systemctl daemon-reload
systemctl enable node_exporter.service
systemctl start node_exporter.service
systemctl status node_exporter.service
编辑prometheus.yml并在scrape_configs节点下添加以下内容:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
安装Grafana
下载地址 安装
wget https://dl.grafana.com/enterprise/release/grafana-enterprise-9.1.3-1.x86_64.rpm
sudo yum install -y grafana-enterprise-9.1.3-1.x86_64.rpm
systemctl enable grafana-server
systemctl start grafana-server
ss -naltp |grep 3000
docker安装
docker run -d --restart=always -p 3000:3000 grafana/grafana
账号密码都是admin
配置数据源
填写Prometheus的IP地址
添加监控模板
Grafana官方提供模板地址: https://grafana.com/grafana/dashboards
本次要导入的模板: https://grafana.com/grafana/dashboards/11074
安装zabbix插件
grafana-cli plugins install alexanderzobnin-zabbix-app
License:
CC BY 4.0