[toc]

一、安装grafana

  1. 1、配置yum源文件
  2. # vim /etc/yum.repos.d/grafana.repo
  3. [grafana]
  4. name=grafana
  5. baseurl=https://packages.grafana.com/oss/rpm
  6. repo_gpgcheck=1
  7. enabled=1
  8. gpgcheck=1
  9. gpgkey=https://packages.grafana.com/gpg.key
  10. sslverify=1
  11. sslcacert=/etc/pki/tls/certs/ca-bundle.crt
  12. 2.通过yum命令安装grafana
  13. # yum -y install grafana
  14. 3.启动grafana并设为开机自启
  15. # systemctl start grafana-server.service
  16. # systemctl enable grafana-server.service

二、安装promethus

  1. 1、下载安装包,下载地址
  2. https://prometheus.io/download/
  3. 2、解压压缩包
  4. # tar fvxz prometheus-2.14.0.linux-amd64.tar.gz
  5. 3、将解压后的目录改名
  6. # mv prometheus-2.13.1.linux-amd64 /opt/prometheus
  7. 4、查看promethus版本
  8. # ./prometheus --version
  9. 5、配置系统服务启动
  10. # vim /etc/systemd/system/prometheus.service
  11. [Unit]
  12. Description=Prometheus Monitoring System
  13. Documentation=Prometheus Monitoring System
  14. [Service]
  15. ExecStart=/opt/prometheus/prometheus \
  16. --config.file /opt/prometheus/prometheus.yml \
  17. --web.listen-address=:9090
  18. [Install]
  19. WantedBy=multi-user.target
  20. 6、加载系统服务
  21. # systemctl daemon-reload
  22. 7、启动服务和添加开机自启动
  23. # systemctl start prometheus
  24. # systemctl enable prometheus

三、ceph mgr prometheus插件配置

  1. # ceph mgr module enable prometheus
  2. # netstat -nltp | grep mgr 检查端口
  3. # curl 127.0.0.1:9283/metrics 测试返回值

四、配置promethus

1、在 scrape_configs: 配置项下添加

  1. vim prometheus.yml
  2. - job_name: 'ceph_cluster'
  3. honor_labels: true
  4. scrape_interval: 5s
  5. static_configs:
  6. - targets: ['10.151.30.125:9283']
  7. labels:
  8. instance: ceph

2、重启promethus服务

  1. # systemctl restart prometheus

3、检查prometheus服务器中是否添加成功

  1. # 浏览器-》 http://x.x.x.x:9090 -》status -》Targets

五、配置grafana

1、浏览器登录 grafana 管理界面
2、添加data sources,点击configuration—》data sources
3、添加dashboard,点击HOME—》find dashboard on grafana.com
4、搜索ceph的dashboard
5、点击HOME—》Import dashboard, 选择合适的dashboard,记录编号