找回密码
 注册
查看: 3072|回复: 1

Prometheus监控Ceph分布式存储

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2021-8-10 11:27:55 | 显示全部楼层 |阅读模式
1.Ceph的Dashboard只适合查看集群状态,生产环境中最好还是把监控ceph纳入到已有的zabbix或Prometheus监控系统中;由于Prometheus是一个restful风格的api,它是通过http或https接口进行数据指标采集的,但是很多被监控的应用并没有http接口,因此需要借助各自应用的exporter进行间接采集;6 f/ U$ e- C! R4 J# H+ F
2.mgr的prometheus_exporter和node_exporter
% m; h* c6 t# d) l: o5 A' w3 ~    1.由于Ceph底层是rados协议没有http接口,所以也需要有单独的exporter进行采集,只需要在ceph的一个节点上安装prometheus_exporter,获得cephX授权后通过mon或mgr查询ceph集群信息后,把采集到的数据转为与prometheus兼容的格式并通过http协议响应prometheus的拉取请求;好在这个prometheus_exporter是直接内置在Ceph的mgr模块中的,只需要启用该模块即可;
' r4 x4 f" ^- @! r, t' m    2.由于mgr内嵌的prometheus_exporter只是监控Ceph系统本身的数据,而每个ceph节点主机的cpu、内存信息还是需要部署node_exporter进行数据采集监控的;
. e9 s! O& s  `& b' k% ]3.1.创建运⾏Prometheus Server进程的系统⽤⼾,并为其创建家⽬录/var/lib/prometheus作为数据存储⽬录;如果公司内部中已有prometheus,可省略下面部分的安装过程,直接进行监控ceph的配置部分即可;
3 j$ T4 }7 [. d( y5 L    ~]# useradd -r -m -d /var/lib/prometheus prometheus  #创建数据目录
7 e: b) w) f( X. g2 N    ~]# tar xf prometheus-2.7.2.linux-amd64.tar.gz -C /usr/local/
; l" w: }+ |4 j# R" E" \' p        #官方下载二进制包解压
7 P' s" {% ]* ~, \/ C  @    ~]# ln /usr/local/prometheus-2.7.2.linux-amd64 /usr/local/prometheus
; k- y, |$ _' u$ D) l# ^- I4 J        #创建软链接) |5 p6 Y. s8 ?7 ], `
    ~]# prometheus --version    #查看prometheus版本
) C9 g2 Q$ j* B    创建Prometheus专⽤的Unit File文件放在/usr/lib/systemd/system/目录下" o+ c& W6 R% {3 ]& g' [4 U) f
        ~]# vim /usr/lib/systemd/system/prometheus.service" @' P$ l9 i" t# g! U
            [Unit]0 _: `0 R8 w1 [  G1 H! [0 i! K% Q/ w
            Documentation=https://prometheus.io9 |2 m3 R9 j: \" ^
            After=network.target
0 _; {) K, c7 X            [Service]) v; G: n. K5 z/ w# i: a! E  H+ c
            EnvironmentFile=-/etc/sysconfig/prometheus4 {% m. t3 ~; k( b) {
            User=prometheus
* s: \" S+ X; Q* V- B$ X9 _1 K            ExecStart=/usr/local/prometheus/prometheus \2 J7 V; j8 H+ F7 Z0 n5 i4 J1 m
                    --storage.tsdb.path=/var/lib/prometheus \
. Q1 ^& r- o/ a0 a9 L3 k0 [. g                    --config.file=/usr/local/prometheus/prometheus.yml \
: t6 V# \4 r/ j1 f- U                    --web.listen-address=0.0.0.0:9090 \: {  I, s! G+ b, p8 g
                    --web.external-url=
" ?. u  w; P8 Q9 k) X            Restart=on-failure
9 W0 y( g$ D7 J# @: p3 c            StartLimitInterval=1
- K8 r7 L5 X$ n' s! R            RestartSec=3* k& h. V$ V5 L$ W( d) t
            [Install]
1 D; F6 G, x4 j7 K3 Q8 g. w1 r# P# f            WantedBy=multi-user.target4 U' \, P+ o" H  z" G5 T7 R
3.2.每个Ceph节点安装node_exporter采集ceph节点主机的数据( S% ~6 @: R/ e! Y% k
    ~]# tar xf node_exporter-0.17.0.linux-amd64.tar.gz -C /usr/local/ 5 {: T! U6 x& [& f7 q3 D* w8 W
    ~]# ln -sv /usr/local/node_exporter-0.17.0.linux-amd64 /usr/local/node_exporte
+ Z0 \7 x$ R  T    ~]# useradd -r -m -d /var/lib/prometheus prometheus
1 \7 L7 H  X' d' D; l0 }  c        创建运⾏Prometheus Server进程的系统⽤⼾,并为其创建家⽬录/var/lib/prometheus作为数据存储⽬录
( k4 M' o, \/ l, P2 Z- k! M% G    ~]# vim /usr/lib/systemd/system/node_exporter.service
7 F! ]4 z$ w6 D7 f        [Unit]8 \; K# Q. ?' j. l6 e* ]
        Documentation=https://github.com/prometheus/node_exporter3 O9 R% p8 b' U  a
        After=network.target
% z, ?* G0 _% x1 B% b4 \        [Service]
8 A6 X/ l. [8 Q5 v: L# W& R9 X        EnvironmentFile=-/etc/sysconfig/node_exporter% x9 A7 C3 V+ j% N+ J: h0 w
        User=prometheus2 I7 l: D7 C) W* ?
        ExecStart=/usr/local/node_exporter/node_exporter \. u. u/ `' |% B# p
            $NODE_EXPORTER_OPTS
9 d- C* {1 j  `5 t  U" @5 i% E        Restart=on-failure
3 o& y2 Z" [/ Z( v0 o3 u        StartLimitInterval=12 ~2 h" ]9 A) \. `. E6 b/ Y$ H- X4 b
        RestartSec=3' }' b5 Y, b/ _/ c# `) f7 X  E
        [Install], o' U3 f4 x9 X
        WantedBy=multi-user.target1 w) J7 V/ ]0 }$ p4 l6 m& k  o
    ~]# systemctl daemon-reload && systemctl start node_exporter.service& G; M" r) v# f5 o% b
    ~]# s -tunpl |grep 9100      #查看监控端口
4 X7 Q+ v% B# M+ ^" q; I2 }        tcp    LISTEN     0      128      :::9100     :::*   users:(("node_exporter",pid=6776,fd=3))
5 T  [! i7 d. P  \3 l/ ^    ~]# curl localhost:9100/metrics  #测试会否采集到指标数据
1 Q7 e1 z" b" y: j* V6 x  `2 u. l3.3.启用Ceph-mgr中的promethues模块9 w4 j+ n  u4 {7 w6 a: ~: t
    ~]# ceph mgr module enable prometheus
; S& z7 X4 y4 F- U9 z# L' @        #Prometheus模块默认监听于TCP协议的9283端⼝
4 j7 {. t; j0 I+ i: O7 t    ~]# ceph mgr services
9 v! c* J, |) }$ O0 e        {
% X# S, V+ L3 w4 k            "dashboard": "http://stor02.cre.io:8080/",) ~: a5 e# p% t" m
            "prometheus": "http://stor02.cre.io:9283/": }+ _$ E0 J* P, h* n
        }
4 R2 y  g- W; Q% F& K  t( h    ~]# ss -tunpl |grep 92832 @: n5 y4 u; q0 y# B7 N4 F
        tcp    LISTEN     0      5        :::9283      :::*    users:(("ceph-mgr",pid=1071,fd=22))
! t/ {1 j+ D# K        #会在Mgr所在的存储节点上开启9283端口
  x. P4 @1 U2 n: l' U( ]3.4.Prometheus的主配置⽂件为prometheus.yml字段和格式解释
9 c3 r% \8 c7 |4 {  X    prometheus.yml文件主要由global、rule_files、scrape_configs、alerting、remote_write和remote_read⼏个配置段组成,其中:7 b0 m* @: K2 v' B
    1.global:全局配置段;7 ~( w  \& \: I
    2.scrape_configs:配置要监控的目标对象# O& L6 g+ g% Q" r% K6 e5 {% Y7 m
        scrape配置集合,⽤于定义监控的⽬标对象(target)的集合,以及描述如何抓取(scrape)相关指标数据的配置参数;通常,每个scrape配置对应于⼀个单独的作业(job),⽽每个targets可通过静态配置(static_configs)直接给出定义,也可基于Prometheus⽀持的服务发现机制进⾏⾃动配置;; N8 V: s! f+ |1 ^! o* z# P
    3.alertmanager_configs:指定配置监控的报警规则
) W( Z/ e, i* J7 R  f- R9 Z8 q1 a; n        可由Prometheus使⽤的Alertmanager实例的集合,以及如何同这些Alertmanager交互的配置参数;每个Alertmanager可通过静态配置(static_configs)直接给出定义,也可基于Prometheus⽀持的服务发现机制进⾏⾃动配置;
$ O- K* W8 e' c/ |  x9 w& A! f    4.remote_write:: p: I, P: j3 I4 _7 V
        配置"远程写"机制,Prometheus需要将数据保存于外部的存储系统(例如InfluxDB)时定义此配置段,随后Prometheus将样本数据通过HTTP协议发送给由URL指定适配器(Adaptor);
( m1 d0 b/ v9 @! U5 J* p# }2 c    5.remote_read:
( ]/ Y+ ~+ y2 Z! i3 D. T        配置"远程读"机制,Prometheus将接收到的查询请求交给由URL指定适配器(Adpater)执⾏,Adapter将请求条件转换为远程存储服务中的查询请求,并将获取的响应数据转换为Prometheus可⽤的格式
8 T# w  h; {$ I* B( H% x' i: d    2.1.scrape配置段& a6 j( J: A. ]6 M. E, g
        1.使⽤static_configs静态配置Job的语法格式:; e) s/ [; r) @4 U! Q4 t
            # The targets specified by the static config.
; |: g  g5 j& E. K# z            targets:$ O( M. G# e$ J4 q  W
              [ - '<host>' ]
$ N6 ]& ~$ i. R' c            # Labels assigned to all metrics scraped from the targets.% a2 w7 l" P' I6 s6 H" [
            labels:
5 E( |( Y( o1 d5 e7 u2 \- W              [ <labelname>: <labelvalue> ... ]( M( E1 j" ?, L1 z5 c# {+ R
        2.使⽤file_sd_configs基于文件发现机制配置Job的语法格式( f* Y. @0 u8 D* E$ _
            [
- l$ w% A; [) r' G: i; }                {
' q6 c5 Y! e0 Q. V1 |. k                    "targets": [ "<host>", ... ],, X8 e: [) K  c. Q0 d
                    "labels": {4 x  p; e. E8 s$ n
                      "<labelname>": "<labelvalue>", ...
; O( G( m; b7 A* ~; s) C" ~5 Q                    }
0 z: l$ K/ Z/ H1 G/ _: h: C! H                },8 m! b, i3 t# T3 X- P
                ...6 Y! k: y' ?4 L. d: Y* \
            ]1 Y$ C+ L- G" a. G* q' T/ b
3.5.配置prometheus监控ceph集群和ceph存储节点主机7 H( @  q+ n2 n5 o
    ~]# vim /etc/prometheus/prometheus.yml# r' u) |1 l$ Y5 v' y1 d' r
        scrape_configs:
! V' c% _/ E( ?/ F          - job_name: 'prometheus'
# J5 v2 n! ~  `: Z1 m% M4 v7 `            static_configs:! {  X& W! ^5 l6 \8 t% V- ^2 Y
            - targets: ['111.231.143.40:9090']2 e8 s  `+ W: y" }3 j
          - job_name: 'node_exporter'
4 `5 d3 v0 y' U1 E: J1 J! D            static_configs:) L) ]* R9 u. T& ?4 J0 r$ z
            - targets: ['stor01.cre.io:9100']
" A# Q9 n( @$ _" T1 J5 D            - targets: ['stor02.cre.io:9100']
5 t  i# [4 v+ z; H            - targets: ['stor03.cre.io:9100']
2 N' B; S5 ?6 F( V5 t          - job_name: 'ceph'
( p0 l3 D, ]; k        #   honor_labels: true9 o) ^, f* _0 o- _+ |# ^) ^- P* g! Y
            static_configs:
9 a7 m% U" k& R+ n5 x0 Y            - targets: ['stor02.cre.io:9283']
  @# O- `' }5 \6 T    注意事项:
& S) t" u4 ^6 D" b& d        1.job_name=node_exporter设置ceph集群的3个主机节点,job_name=ceph设置manager所在节点的主机名和Prometheus模块的端口;+ S# v* U9 Q$ h* l
        2.注意prometheus中的targets中要写主机的FQDN格式的主机名,否者ceph dashboard中host details中不能正常显示监控数据,因为ceph dashboard是使用FQDN格式的主机名查询监控信息,如果prometheus中写的是IP会导致查询不到;而grafana使用IP查询,所以在grafana中不会有这种错误;# |* x* ^! Q% z9 |# ~
        3.honor_labels=true必须有且设置为true,否者会导致CephDashbaord中显示grafana某些面板没有数据出现(这个待验证,个人认为可以设置此参数);+ i  Z5 x- b6 d: N
        4.如果ceph集群中部署了多个manager,需要在job_name=ceph中添加多个targets将所有magr的地址都写上;(本ceph集群只部署了一个mgr)' W7 g2 o8 s5 l8 j% C$ j
~]# systemctl daemon-reload5 @0 ~. M( b' U& R% @3 @
~]# systemctl start prometheus && systemctl enable prometheus  #设置开启自启
. T' x( n$ C+ A验证配置是否抓取到数据:
9 b, M; l  w8 Q5 i2 C8 L' j1 Z    登录prometheus地址:http://192.168.10.10:9090,查看Targets页面上的prometheus、3个node、ceph mgr是否都是UP的即可:

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2021-8-10 11:28:56 | 显示全部楼层
1.Ceph的Dashboard只适合查看集群状态,生产环境中最好还是把监控ceph纳入到已有的zabbix或Prometheus监控系统中;由于Prometheus是一个restful风格的api,它是通过http或https接口进行数据指标采集的,但是很多被监控的应用并没有http接口,因此需要借助各自应用的exporter进行间接采集;! v+ s& |+ U5 U" E6 P
2.mgr的prometheus_exporter和node_exporter3 P5 u9 s. m1 V- T+ X, m
    1.由于Ceph底层是rados协议没有http接口,所以也需要有单独的exporter进行采集,只需要在ceph的一个节点上安装prometheus_exporter,获得cephX授权后通过mon或mgr查询ceph集群信息后,把采集到的数据转为与prometheus兼容的格式并通过http协议响应prometheus的拉取请求;好在这个prometheus_exporter是直接内置在Ceph的mgr模块中的,只需要启用该模块即可;; O9 t: L7 a. U5 y+ Y
    2.由于mgr内嵌的prometheus_exporter只是监控Ceph系统本身的数据,而每个ceph节点主机的cpu、内存信息还是需要部署node_exporter进行数据采集监控的;
) M+ B+ I8 N3 D- g6 z7 j% N0 K9 a3.1.创建运⾏Prometheus Server进程的系统⽤⼾,并为其创建家⽬录/var/lib/prometheus作为数据存储⽬录;如果公司内部中已有prometheus,可省略下面部分的安装过程,直接进行监控ceph的配置部分即可;. g$ I$ U& n# v  T1 U4 z0 R& p
    ~]# useradd -r -m -d /var/lib/prometheus prometheus  #创建数据目录8 d( u- L+ i  ]  k) J6 _6 A( f! V
    ~]# tar xf prometheus-2.7.2.linux-amd64.tar.gz -C /usr/local/: e: p  `4 a- y7 f+ t6 F; n) B7 x1 p
        #官方下载二进制包解压
1 W' i8 k* u* t    ~]# ln /usr/local/prometheus-2.7.2.linux-amd64 /usr/local/prometheus
, d6 G; S8 `# i3 r        #创建软链接
  `. H2 S  a* y& Z% [3 S! O    ~]# prometheus --version    #查看prometheus版本; s' u2 \+ A, S' ]  i% m5 y- x
    创建Prometheus专⽤的Unit File文件放在/usr/lib/systemd/system/目录下) ]; t+ _8 P; F3 O* |; U+ c+ b
        ~]# vim /usr/lib/systemd/system/prometheus.service# Q8 C6 t% d& k/ a, }* W4 u
            [Unit]
* [! m! m' k& |            Documentation=https://prometheus.io$ G; X1 G3 [, [5 M0 d
            After=network.target
/ S! A. w. X( |# Q            [Service]
* I- s4 Y. G# p7 b* K- }3 t            EnvironmentFile=-/etc/sysconfig/prometheus% A/ o6 T/ C& z' F% E' m
            User=prometheus
+ X$ ~/ {' z5 \' s            ExecStart=/usr/local/prometheus/prometheus \
( W5 W7 G' _% P. t4 r! Z# S: j                    --storage.tsdb.path=/var/lib/prometheus \+ m5 k: p8 b8 P5 L8 l5 s8 m
                    --config.file=/usr/local/prometheus/prometheus.yml \
; n& v0 u. A. l2 B                    --web.listen-address=0.0.0.0:9090 \
3 U  u2 D. D$ }+ i/ q! e; G                    --web.external-url=/ @  v9 [# s% U- I) `$ C! n0 d
            Restart=on-failure
( y' V0 O6 n: d  D9 n            StartLimitInterval=1
8 J0 A( {# Z+ ~! d- ~            RestartSec=3
* \2 z" E# _2 K/ R" P! I            [Install]  I& F1 s' M0 A9 J' @/ j+ w) {& S' M
            WantedBy=multi-user.target
6 {1 ^3 [  P$ s( J* G) |3.2.每个Ceph节点安装node_exporter采集ceph节点主机的数据+ m$ k$ j7 F' ?9 p
    ~]# tar xf node_exporter-0.17.0.linux-amd64.tar.gz -C /usr/local/
3 H% {: k, t2 _" h( L8 L% Z    ~]# ln -sv /usr/local/node_exporter-0.17.0.linux-amd64 /usr/local/node_exporte
8 j9 w( X4 s% E' h7 v% n: z    ~]# useradd -r -m -d /var/lib/prometheus prometheus" k  ?1 k8 z! W+ l1 y
        创建运⾏Prometheus Server进程的系统⽤⼾,并为其创建家⽬录/var/lib/prometheus作为数据存储⽬录
# ]) q% J( l+ ^" g# [: l3 V    ~]# vim /usr/lib/systemd/system/node_exporter.service
. K# S( w0 e( V) F3 h4 o; v" X        [Unit]
3 Q1 S+ [9 @: D1 [4 @' ^        Documentation=https://github.com/prometheus/node_exporter9 g2 U. v1 y3 t6 w5 M% R# F+ q  E( u
        After=network.target
! t" s2 z9 }8 a+ x% \/ P( e- r        [Service]' ^9 S& A, |: v# Z% u
        EnvironmentFile=-/etc/sysconfig/node_exporter
# u/ v1 c9 x) M        User=prometheus: J0 C3 A( P7 h3 P) }( c( k
        ExecStart=/usr/local/node_exporter/node_exporter \4 A* B& S, m6 f* M# w0 i/ x: Z5 G
            $NODE_EXPORTER_OPTS. y# A7 L- I" B+ h1 H/ H6 Q
        Restart=on-failure
9 e1 ?) `0 H6 z) X4 v' ^$ J9 K        StartLimitInterval=1
% T# c5 G# A' D# N( p+ Q        RestartSec=3
) t9 `* q6 w" n5 v" Y. ^- K        [Install]
! |- u( k3 T1 c/ m* }: u3 {" X        WantedBy=multi-user.target
3 Y7 p/ b4 d' n- p) Q: ]    ~]# systemctl daemon-reload && systemctl start node_exporter.service4 T- B6 d7 A4 p: j9 o# p/ A; O3 K
    ~]# s -tunpl |grep 9100      #查看监控端口* K: G; G; L4 o$ h/ I
        tcp    LISTEN     0      128      :::9100     :::*   users:(("node_exporter",pid=6776,fd=3))9 u6 D2 X7 f6 S  v! w
    ~]# curl localhost:9100/metrics  #测试会否采集到指标数据
2 f* I1 L- l4 w8 B9 L3.3.启用Ceph-mgr中的promethues模块* t1 x, y2 Q7 k" Z
    ~]# ceph mgr module enable prometheus" `6 t7 o3 p% U3 V' `$ o" F
        #Prometheus模块默认监听于TCP协议的9283端⼝/ K' V8 K! K# D7 J( i
    ~]# ceph mgr services9 Y' N6 W( c; N
        {" l% u  Z! m4 w
            "dashboard": "http://stor02.cre.io:8080/",8 V+ K5 L1 m8 E
            "prometheus": "http://stor02.cre.io:9283/"; A# \' d: J- V, \. Z+ X$ J# L
        }
8 j7 @* S# \9 F- p    ~]# ss -tunpl |grep 9283
% L9 o* b9 U4 }* a# h! x, N) f        tcp    LISTEN     0      5        :::9283      :::*    users:(("ceph-mgr",pid=1071,fd=22))
3 B# G/ _9 ^3 m6 i$ y        #会在Mgr所在的存储节点上开启9283端口
4 Q( G+ _  C4 y8 c$ B. d3.4.Prometheus的主配置⽂件为prometheus.yml字段和格式解释2 b: Y9 Y% d. y9 p$ T4 E
    prometheus.yml文件主要由global、rule_files、scrape_configs、alerting、remote_write和remote_read⼏个配置段组成,其中:
! i: e7 S5 o. q' _  y# Z% V    1.global:全局配置段;
" T/ |7 [4 C9 \/ w    2.scrape_configs:配置要监控的目标对象& S' F8 b" V, A$ Q% Q+ _
        scrape配置集合,⽤于定义监控的⽬标对象(target)的集合,以及描述如何抓取(scrape)相关指标数据的配置参数;通常,每个scrape配置对应于⼀个单独的作业(job),⽽每个targets可通过静态配置(static_configs)直接给出定义,也可基于Prometheus⽀持的服务发现机制进⾏⾃动配置;
1 t: @, A% V; t  T" q    3.alertmanager_configs:指定配置监控的报警规则
; F: g: M, O3 b0 m, v% i$ g7 b        可由Prometheus使⽤的Alertmanager实例的集合,以及如何同这些Alertmanager交互的配置参数;每个Alertmanager可通过静态配置(static_configs)直接给出定义,也可基于Prometheus⽀持的服务发现机制进⾏⾃动配置;
7 `& o* h" t. N    4.remote_write:0 q  ^, a% \% \1 n# J" x  x
        配置"远程写"机制,Prometheus需要将数据保存于外部的存储系统(例如InfluxDB)时定义此配置段,随后Prometheus将样本数据通过HTTP协议发送给由URL指定适配器(Adaptor);4 n; X  W6 {+ f1 S# q
    5.remote_read:
. }  h( Y+ z0 t. H# N        配置"远程读"机制,Prometheus将接收到的查询请求交给由URL指定适配器(Adpater)执⾏,Adapter将请求条件转换为远程存储服务中的查询请求,并将获取的响应数据转换为Prometheus可⽤的格式
5 L9 e0 p$ K/ p  l6 r! b$ k    2.1.scrape配置段
+ `  q, R2 Z5 }( H3 `        1.使⽤static_configs静态配置Job的语法格式:
$ v) L& [; Q: v5 s            # The targets specified by the static config.- ], y. D/ v& n% E1 R
            targets:% k$ }5 W* z7 s: N0 P( E" z
              [ - '<host>' ]
  x& V4 }5 O4 @            # Labels assigned to all metrics scraped from the targets.9 V3 U, v, ^3 t2 D  d: G0 X% m
            labels:8 i! F6 b& }! ]. q" r2 I" z* f0 v
              [ <labelname>: <labelvalue> ... ]  {( U2 }9 m% ^5 J1 r7 z
        2.使⽤file_sd_configs基于文件发现机制配置Job的语法格式
" d% g* M/ n1 y! \7 p3 Q9 p            [
: X8 J) @2 q) Q1 i* s3 q; m                {
/ q2 x, T& ~8 x; h0 z. D                    "targets": [ "<host>", ... ],. R- b* b* x/ p, c  Y- {+ ?, S* x# _
                    "labels": {
+ \. Y  i9 s* N                      "<labelname>": "<labelvalue>", ...1 A/ X  i( q; h" `% z) e+ S
                    }
( y9 U) Q- g% Z% ?  R8 }                },
& d# F, C5 c# a7 U0 ^                ..." S/ ^) f7 o) X, u" H5 C+ F1 Q
            ]/ W  ?9 x5 ?! h6 A1 ?
3.5.配置prometheus监控ceph集群和ceph存储节点主机* x, r+ Y5 \( L1 K9 b& A0 C
    ~]# vim /etc/prometheus/prometheus.yml$ r7 L2 J3 b% Y5 W
        scrape_configs:9 s9 K% \& `" ?4 g0 r9 _( u  \
          - job_name: 'prometheus'
, x! a7 T! f: s- G0 J            static_configs:
3 t+ o6 K" x# G  i6 p            - targets: ['111.231.143.40:9090']8 B4 _) C' Y6 D, s  d
          - job_name: 'node_exporter'5 B5 n& G/ x( V5 z' k
            static_configs:
. v# @1 x; T: F  Y) X% Y4 F            - targets: ['stor01.cre.io:9100']
5 D% z! ^3 G6 v, _  m  r, u: R            - targets: ['stor02.cre.io:9100']
8 o" x& U( S4 j8 y+ N% G/ _            - targets: ['stor03.cre.io:9100']
, U+ p; h9 q5 U# W5 L2 v, ?          - job_name: 'ceph'
2 m. J3 R8 V. T! P# U2 ?# x* d        #   honor_labels: true& u' G1 N) i/ }3 i. @
            static_configs:! e" I' |5 z8 g& @8 s8 F0 |
            - targets: ['stor02.cre.io:9283']
( x0 ]% Q( h& _) Z    注意事项:1 O' X8 A. I; h  F, X1 L
        1.job_name=node_exporter设置ceph集群的3个主机节点,job_name=ceph设置manager所在节点的主机名和Prometheus模块的端口;( Z* t9 ?6 R8 y  @3 c4 F/ J
        2.注意prometheus中的targets中要写主机的FQDN格式的主机名,否者ceph dashboard中host details中不能正常显示监控数据,因为ceph dashboard是使用FQDN格式的主机名查询监控信息,如果prometheus中写的是IP会导致查询不到;而grafana使用IP查询,所以在grafana中不会有这种错误;
- F* D4 _6 P* F  Y# u3 z- O        3.honor_labels=true必须有且设置为true,否者会导致CephDashbaord中显示grafana某些面板没有数据出现(这个待验证,个人认为可以设置此参数);5 o# D( W9 Y7 Y
        4.如果ceph集群中部署了多个manager,需要在job_name=ceph中添加多个targets将所有magr的地址都写上;(本ceph集群只部署了一个mgr)% \  P5 R6 {( v4 K9 k: C9 A
~]# systemctl daemon-reload- v4 k; Z' t3 ]* X4 q+ D# d" Y
~]# systemctl start prometheus && systemctl enable prometheus  #设置开启自启
; G4 E# Q0 K9 N! f  J验证配置是否抓取到数据:
5 Q3 z5 x; j" e3 r6 X    登录prometheus地址:http://192.168.10.10:9090,查看Targets页面上的prometheus、3个node、ceph mgr是否都是UP的即可:, B; c* j, m: `4 ~$ E
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 00:58 , Processed in 0.017049 second(s), 23 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表