prometheus监控ceph集群环境

一.prometheus监控ceph集群环境

1.启用prometheus模块

[root@ceph141 ~]# ceph mgr module enable prometheus


Prometheus模块也是mgr组件的模块之一,用于Prometheus监控Ceph集群提供遍历。

参考链接:
	https://docs.ceph.com/en/nautilus/mgr/dashboard/#enabling-the-embedding-of-grafana-dashboards

2.验证模块是否启用成功

[root@ceph141 ~]# ceph mgr module ls | jq .enabled_modules
[
  "dashboard",
  "iostat",
  "prometheus",
  "restful"
]
[root@ceph141 ~]# 
	

3.查看服务的访问地址

[root@ceph141 ~]# ceph mgr services
{
    "dashboard": "https://ceph141:8443/",
    "prometheus": "http://ceph141:9283/"
}
[root@ceph141 ~]# 
[root@ceph141 ~]# 
[root@ceph141 ~]# ss -ntl | grep 9283
LISTEN     0      5         [::]:9283                  [::]:*                  
[root@ceph141 ~]# 

4.访问ceph的exporter

http://ceph141:9283/metrics

5.修改prometheus的配置文件

[root@prometheus-server31 ~]# vim /yinzhengjie/softwares/prometheus/prometheus.yml 
...
global:
  scrape_interval: 5s

scrape_configs:
  ...
  - job_name: "yinzhengjie_ceph_custom_metrics"
    static_configs:
    - targets:
      - 10.0.0.142:9283
[root@prometheus-server31 ~]

6.热加载配置

[root@prometheus-server31 ~]# curl -X POST http://10.0.0.31:9090/-/reload

7.grafana去prometheus采集数据

2842: 
	ceph集群模板

5336: 
	OSD模板

5342:
	存储池模板

二.监控ceph集群宿主机

1.ceph所有节点安装node-exporter

[root@ceph141 ~]# cat install-node-exporter.sh 
#!/bin/bash
# auther: JasonYin


VERSION=1.7.0
SOFTWARE=node_exporter-${VERSION}.linux-amd64.tar.gz
URL=https://github.com/prometheus/node_exporter/releases/download/v${VERSION}/${SOFTWARE}
DOWNLOAD=./download
INSTALLDIR=/yinzhengjie/softwares
BASEDIR=${INSTALLDIR}/node_exporter-${VERSION}.linux-amd64

# 判断目录是否存在,若不存在则创建
[ -d $INSTALLDIR ] || mkdir -pv ${INSTALLDIR}
[ -d $DOWNLOAD ] || mkdir -pv ${DOWNLOAD}

# 判断系统是否安装curl
# [ -f /usr/bin/wget ] || apt update && apt -y install wget

# 判断文件是否存在,若不存在则下载
[ -s ${DOWNLOAD}/${SOFTWARE} ] || wget $URL -O ${DOWNLOAD}/${SOFTWARE}

if [ $? -eq 0 ]; then
  # 解压文件软件包
  tar xf ${DOWNLOAD}/${SOFTWARE} -C ${INSTALLDIR}

  # 生成启动脚本
cat > /etc/systemd/system/node-exporter.service <<EOF
[Unit]
Description=yinzhengjie Linux Node Exporter
Documentation=https://prometheus.io/docs/introduction/overview/
After=network.target

[Service]
ExecStart=${BASEDIR}/node_exporter --web.listen-address=:9100

[Install]
WantedBy=multi-user.target
EOF

  # 将服务设置为开机自启动
  systemctl daemon-reload
  systemctl enable --now node-exporter.service
fi
[root@ceph141 ~]#
[root@ceph141 ~]# bash install-node-exporter.sh 
Created symlink from /etc/systemd/system/multi-user.target.wants/node-exporter.service to /etc/systemd/system/node-exporter.service.
[root@ceph141 ~]#

2.修改prometheus的配置文件

[root@prometheus-server31 ~]# vim /yinzhengjie/softwares/prometheus/prometheus.yml 
...
global:
  scrape_interval: 5s

scrape_configs:
  ...
  - job_name: "yinzhengjieceph-node-exporter"
    honor_labels: true
    static_configs:
    - targets:
      - 10.0.0.141:9100
      - 10.0.0.142:9100
      - 10.0.0.143:9100

3.热加载配置

[root@prometheus-server31 ~]# curl -X POST http://10.0.0.31:9090/-/reload

4.grafana去prometheus采集数据

1860
posted @ 2021-01-24 23:57  尹正杰  阅读(182)  评论(0编辑  收藏  举报