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

一、环境介绍
系统: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]#

制作系统服务
网页访问测试
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

访问测试

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’

加入被监控端
重启服务

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/ #访问页面
访问页面
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
二选一导入一个监控模板
在这里插入图片描述

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值