自学内容网 自学内容网

基于openEuler22.03SP4部署Prometheus+Grafana

测试环境

Virtual Box,openEuler-22.03-LTS-SP4-x86_64-dvd.iso,4 vCPU, 8G RAM, 60 vDisk。最小化安装。需联网。

系统环境

关闭防火墙

systemctl stop firewalld

systemctl disable firewalld

systemctl status firewalld

selinux关闭

sed -ri ‘s/SELINUX=enforcing/SELINUX=disabled/’ /etc/selinux/config

安装Prometheus

Prometheus官网

下载prometheus的LTS版本

https://prometheus.io/download/

tar -zxvf prometheus-2.53.3.linux-amd64.tar.gz -C /usr/local/

mv /usr/local/prometheus-2.53.3.linux-amd64/ /usr/local/prometheus

cd /usr/local/prometheus

/usr/local/prometheus/prometheus --config.file=“/usr/local/prometheus/prometheus.yml” &

查看9090端口是否开启

ss -anlt | grep 9090

通过浏览器进入页面

http://192.168.31.244:9090/

数据展示

http://192.168.31.244:9090/metrics

安装Grafana

https://dl.grafana.com/enterprise/release/grafana-enterprise-11.4.0-1.x86_64.rpm

dnf install -y grafana-enterprise-11.4.0-1.x86_64.rpm

systemctl enable grafana-server

systemctl start grafana-server

浏览器输入http://192.168.31.244:3000

账号密码默认admin/admin

添加数据源,添加你的Prometheus服务地址和端口。

添加grafana监控模板,如果可以连接到外网, 那么直接输入id自动下载,如果不能连接外网,则需要访问
https://grafana.com/grafana/dashboards/网站寻找。比如12633, 8919模板,下载json文件导入即可。

安装node_exporter

tar -zxvf node_exporter-1.8.2.linux-amd64.tar.gz

cp node_exporter-1.8.2.linux-amd64/node_exporter /usr/local/bin/

为node_erporter创建service,使用systemctl管理

vi /usr/lib/systemd/system/node_exporter.service

[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/bin/node_exporter
Restart=on-fallure
[Install]
WantedBy=multi-user.target

systemctl start node_exporter.service

systemctl enable node_exporter.service

修改监控主机Prometheus服务的配置文件,添加job

vi /usr/local/prometheus/prometheus.yml

scrape_configs:
  - job_name: 'Kingstar_ARM_prometheus'
    static_configs:
        - targets: ['192.168.31.244:9100']

用promtool检测配置文件是否正确

/usr/local/prometheus/promtool check config /usr/local/prometheus/prometheus.yml

重启prometheus

查看http://192.168.31.244:9090/targets地址,job和被监控节点正确显示。

刷新Grafana,仪表盘已显示主机。


原文地址:https://blog.csdn.net/qlau2007/article/details/145107162

免责声明:本站文章内容转载自网络资源,如侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!