prometheus+grafana监控搭建

官网地址

源码包下载地址
prometheus: https://prometheus.io/
grafana:https://grafana.com/grafana/

监控模板–下载地址:https://grafana.com/grafana/dashboards/1860?pg=dashboards&plcmt=featured-sub1

监控端配置

下载源码包后上传到服务器

1
2
3
4
5
6
7
8
9
# 解压
tar xf prometheus-2.25.0.linux-amd64.tar.gz
# 重命名
mv prometheus-2.25.0.linux-amd64 prometheus
# 启动
cd prometheus
nohup ./prometheus &
# 查看端口是否被监听
lsof -i:9090

登录prometheus后台查看是否启动成功(默认端口9090)

没问题后安装grafana

1
2
3
4
5
6
7
8
# 下载源码包
wget https://dl.grafana.com/oss/release/grafana-7.4.3-1.x86_64.rpm
# 安装
yum install grafana-7.4.3-1.x86_64.rpm -y
# 启动
/etc/init.d/grafana-server start
# 查看端口是否被监听
lsof -i:3000

登录grafana后台查看(默认端口3000)

添加数据来源

选择添加

选择prometheus然后点击select

输入名字以及prometheus的url–url为prometheus服务器的地址和端口

点击保存测试

被监控端配置

1
2
3
4
5
6
7
8
9
# 解压
tar xf prometheus-2.25.0.linux-amd64.tar.gz
# 重命名
mv prometheus-2.25.0.linux-amd64 prometheus
# 启动
cd prometheus
nohup ./prometheus &
# 查看端口是否被监听
lsof -i:9090

监控端添加被监控服务器

监控端配置文件添加被监控端

1
2
3
4
5
6
7
vim   prometheus.yml 
*******
- job_name: 'Test'
static_configs:
- targets: ['192.168.1.104:9090']

# 添加被监控ip:端口 保存退出


重启prometheus

1
2
3
4
5
6
7
8
[root@centos6 prometheus]# ps aux | grep prometh
root 28752 0.0 0.7 1101676 61596 pts/1 Sl 00:56 0:00 ./prometheus
root 28777 0.0 0.0 103324 892 pts/1 S+ 01:11 0:00 grep prometh
[root@centos6 prometheus]# kill -9 28752
[1]+ Killed nohup ./prometheus
[root@centos6 prometheus]# nohup ./prometheus &
[1] 28778
[root@centos6 prometheus]# nohup: ignoring input and appending output to `nohup.out'

查看添加成功了并且状态是up

grafana配置被监控端

选择import导入

选择上传JSON文件

选择之前下载好的json文件

填写名字以及选择数据源

  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • Copyrights © 2019-2023 XIN LONG
  • 访问人数: | 浏览次数:

请我喝杯咖啡吧~

支付宝
微信