centos7.8搭建prometheus+grafana监控平台
  UrUE11xuNpHw 2023年11月02日 44 0


一、环境介绍
系统:centos7.8

软件:监控端–>prometheus-2.40.0-rc.0.linux-amd64.tar.gz

web展示:grafana-enterprise-9.2.3-1.x86_64.rpm

被监控端 --> node_exporter-1.4.0.linux-amd64.tar.gz

grafana官网下载 :https://grafana.com/grafana/download

prometheus官网下载: https://prometheus.io/download/

二、prometheus安装配置
1、监控端配置prometheus
tar zxf prometheus-2.40.0.linux-amd64.tar.gz -C /opt/
ln -sv /opt/prometheus-2.40.0.linux-amd64/ /opt/prometheus
groupadd prometheus
useradd -g prometheus -m -d /opt/prometheus/ -s /sbin/nologin prometheus

mkdir /opt/prometheus/data
chown -R prometheus:prometheus /opt/prometheus/*
cd /opt/prometheus
./promtool check config prometheus.yml #检测语法
./prometheus --config.file=prometheus.yml #启动服务

编辑文件配置(制作系统服务)
[root@localhost /opt]# cat /usr/lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus Monitoring System
Documentation=Prometheus Monitoring System

[Service]
Restart=on-failure
ExecStart=/opt/prometheus/prometheus
–config.file=/opt/prometheus/prometheus.yml
–storage.tsdb.path=/usr/local/prometheus/data
–web.listen-address=:9090

[Install]
WantedBy=multi-user.target
[root@localhost /opt]#

centos7.8搭建prometheus+grafana监控平台_grafana


网页访问测试

​ http://ip地址:9090/​​ 2、被监控端配置node_exporter

下载被监控端软件地址:https://github.com/prometheus/node_exporter/releases/tag/v1.4.0


tar -zxf node_exporter-1.4.0.linux-amd64.tar.gz -C /opt/

cd /opt/node_exporter-1.4.0.linux-amd64/

nohup ./node_exporter &

​http://x.x.x.x:9100/metrics​

centos7.8搭建prometheus+grafana监控平台_linux_02

3、将 node_exporter客户端加入prometheus.yml配置中
策略:允许指定ip地址访问本机端口
firewall-cmd --permanent --add-rich-rule ‘rule family=ipv4 source address=192.168.0.1/2 port port=9100 protocol=tcp accept’
或者开放9100端口
firewall-cmd --zone=public --add-port=9100/tcp --permanent
举个例子:

  • job_name: ‘Linux’
    static_configs:
  • targets: [‘192.168.142.132:9100’,‘192.168.142.134:9100’] 可以是多个,可以单个,逗号隔开
    labels:
    group: ‘client-node-exporter’

centos7.8搭建prometheus+grafana监控平台_grafana_03


重启服务

systemctl restart prometheus.service

三、grafana安装配置
wget https://dl.grafana.com/enterprise/release/grafana-enterprise-9.2.3-1.x86_64.rpm
yum install grafana-enterprise-9.2.3-1.x86_64.rpm
systemctl daemon-reloadsystemctl enable grafana-server.service
systemctl start grafana-server.service

http://ip地址:3000/ #访问页面

centos7.8搭建prometheus+grafana监控平台_prometheus_04


centos7.8搭建prometheus+grafana监控平台_grafana_05


centos7.8搭建prometheus+grafana监控平台_ip地址_06


centos7.8搭建prometheus+grafana监控平台_grafana_07


centos7.8搭建prometheus+grafana监控平台_prometheus_08


centos7.8搭建prometheus+grafana监控平台_linux_09


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  9E2BTpjt8nym   2023年12月06日   34   0   0 WindowsgitCentOS
UrUE11xuNpHw