找回密码
 注册
查看: 3073|回复: 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进行间接采集;
, H' b$ @6 E  c* J0 A3 W2.mgr的prometheus_exporter和node_exporter
$ [/ _& `+ t. C7 f! Q- c    1.由于Ceph底层是rados协议没有http接口,所以也需要有单独的exporter进行采集,只需要在ceph的一个节点上安装prometheus_exporter,获得cephX授权后通过mon或mgr查询ceph集群信息后,把采集到的数据转为与prometheus兼容的格式并通过http协议响应prometheus的拉取请求;好在这个prometheus_exporter是直接内置在Ceph的mgr模块中的,只需要启用该模块即可;% ~. k* C. F3 m+ c+ t6 I
    2.由于mgr内嵌的prometheus_exporter只是监控Ceph系统本身的数据,而每个ceph节点主机的cpu、内存信息还是需要部署node_exporter进行数据采集监控的;; N1 C  l# R: k- V% y
3.1.创建运⾏Prometheus Server进程的系统⽤⼾,并为其创建家⽬录/var/lib/prometheus作为数据存储⽬录;如果公司内部中已有prometheus,可省略下面部分的安装过程,直接进行监控ceph的配置部分即可;
- r. K! j3 S0 Q& j) \9 D    ~]# useradd -r -m -d /var/lib/prometheus prometheus  #创建数据目录0 @, _2 K: v# ~
    ~]# tar xf prometheus-2.7.2.linux-amd64.tar.gz -C /usr/local/' p6 ?8 u  u- g7 m6 P, M
        #官方下载二进制包解压
6 c  \2 B8 r5 w5 _; n' [. J0 s    ~]# ln /usr/local/prometheus-2.7.2.linux-amd64 /usr/local/prometheus* ?. f! |6 x7 J9 C- L) V$ K( a
        #创建软链接+ H, r( n: j% E* I, n
    ~]# prometheus --version    #查看prometheus版本
$ O5 m( K# A8 q  m    创建Prometheus专⽤的Unit File文件放在/usr/lib/systemd/system/目录下
: J% z; q% n3 ~- ^. b5 R        ~]# vim /usr/lib/systemd/system/prometheus.service
% G/ Q( i. ^; t# Z. G6 y3 E* _            [Unit], u" M" h2 [7 K/ V: }$ L
            Documentation=https://prometheus.io
+ T3 F+ B; c" k5 ]$ b1 [: ~5 X            After=network.target( R: b" a* v& K/ ?
            [Service]
8 ~( M4 k* }7 `. p) e            EnvironmentFile=-/etc/sysconfig/prometheus' q  m! e' Q9 f$ l' [- z5 b6 U6 \9 x
            User=prometheus# V) H/ D; @, E* P
            ExecStart=/usr/local/prometheus/prometheus \
7 n$ `& d! T% _+ ^5 F( N                    --storage.tsdb.path=/var/lib/prometheus \& u1 q# g4 J$ |$ Q# L
                    --config.file=/usr/local/prometheus/prometheus.yml \
0 f4 ?, v$ |4 \  \                    --web.listen-address=0.0.0.0:9090 \3 ]" y: O  O* ]! [3 Q/ v
                    --web.external-url=
  I5 I' J" O7 h& V            Restart=on-failure0 u& l$ n! B. B: z+ D/ m
            StartLimitInterval=1
9 Y, k" I" z6 |            RestartSec=3
" ~1 {) O( `& X' M            [Install]
3 J7 m( d1 J3 }, e" n( t  x6 k            WantedBy=multi-user.target8 O2 d8 d; {, ~! P$ S
3.2.每个Ceph节点安装node_exporter采集ceph节点主机的数据
' y" u) C, ~! D1 b" l    ~]# tar xf node_exporter-0.17.0.linux-amd64.tar.gz -C /usr/local/
; v8 e0 Z6 l" J    ~]# ln -sv /usr/local/node_exporter-0.17.0.linux-amd64 /usr/local/node_exporte
" S4 k: v6 U; s; ~  _6 v    ~]# useradd -r -m -d /var/lib/prometheus prometheus  T8 f( I3 q5 R% d! ^. a) |
        创建运⾏Prometheus Server进程的系统⽤⼾,并为其创建家⽬录/var/lib/prometheus作为数据存储⽬录: m. K+ b1 k. H+ i$ s4 D9 b  m9 A
    ~]# vim /usr/lib/systemd/system/node_exporter.service2 {  x+ S0 Q" w" x
        [Unit]0 W5 q" J# C5 j# I2 {) G; o
        Documentation=https://github.com/prometheus/node_exporter
+ G! Q5 |+ T3 l% [; l        After=network.target
! }1 j7 Y& M# @        [Service]
  {6 ^; ?2 k$ v; p4 c        EnvironmentFile=-/etc/sysconfig/node_exporter9 t& M9 D2 o8 T8 {2 X
        User=prometheus
# y0 @* s$ L9 M. t/ c# _# _9 b( I! d/ D        ExecStart=/usr/local/node_exporter/node_exporter \
/ Q0 ]  o! Y( M* u1 b/ [            $NODE_EXPORTER_OPTS
0 S. o) f  N  H) Q3 M* Q) g        Restart=on-failure
" R, q. M! P8 Y. R9 t- A' }        StartLimitInterval=1
  q8 V6 j2 M* {1 ?2 C8 A& \3 i* D8 _        RestartSec=39 r0 F, }. _$ [3 w( h
        [Install]
1 a8 s  v5 W* ^" g3 `        WantedBy=multi-user.target7 e9 ~: D+ S6 V1 O3 p6 Q, v* j
    ~]# systemctl daemon-reload && systemctl start node_exporter.service* {' S" ^# l* D3 }. m. h
    ~]# s -tunpl |grep 9100      #查看监控端口
& d, [2 `' {$ C; B9 c        tcp    LISTEN     0      128      :::9100     :::*   users:(("node_exporter",pid=6776,fd=3))
& ^6 W/ d8 K& e    ~]# curl localhost:9100/metrics  #测试会否采集到指标数据% A" E0 r2 B( }1 y3 I2 J1 K3 t& r, j  n
3.3.启用Ceph-mgr中的promethues模块4 X& d' z1 y2 i9 U, w
    ~]# ceph mgr module enable prometheus* _) j+ b4 l2 k1 i: E/ ^0 T( e
        #Prometheus模块默认监听于TCP协议的9283端⼝7 S( N4 `0 X8 p) }' P( G
    ~]# ceph mgr services4 x$ s- O1 v9 C/ Y" a, B! b$ H8 K( |
        {
" S! O5 T0 K: q" t  v5 o            "dashboard": "http://stor02.cre.io:8080/",
1 Y4 ]" q6 \* G$ R' N: m            "prometheus": "http://stor02.cre.io:9283/"0 f+ g7 v. F4 [0 c2 y) l
        }2 v2 g# a+ l( o+ u( z+ r/ h7 l6 S1 M
    ~]# ss -tunpl |grep 92832 g4 t4 `& ^% N6 a9 ^: X2 ^) `
        tcp    LISTEN     0      5        :::9283      :::*    users:(("ceph-mgr",pid=1071,fd=22))
6 p7 P- e$ l. R8 C$ j5 ]0 [0 I$ i        #会在Mgr所在的存储节点上开启9283端口% r( V1 w0 j; B" M
3.4.Prometheus的主配置⽂件为prometheus.yml字段和格式解释4 k+ C: L1 B& A/ m  q# g& Y; R
    prometheus.yml文件主要由global、rule_files、scrape_configs、alerting、remote_write和remote_read⼏个配置段组成,其中:# ?4 ]# K: L  O7 j/ A1 q
    1.global:全局配置段;! G( k. j6 t8 }0 o( Z. M& u+ \0 `
    2.scrape_configs:配置要监控的目标对象+ p; x& {# V1 Q5 H- B
        scrape配置集合,⽤于定义监控的⽬标对象(target)的集合,以及描述如何抓取(scrape)相关指标数据的配置参数;通常,每个scrape配置对应于⼀个单独的作业(job),⽽每个targets可通过静态配置(static_configs)直接给出定义,也可基于Prometheus⽀持的服务发现机制进⾏⾃动配置;  m6 Z5 Z8 P; E! l7 Z8 s
    3.alertmanager_configs:指定配置监控的报警规则
8 e" [; k* v! n8 F7 F# x6 p        可由Prometheus使⽤的Alertmanager实例的集合,以及如何同这些Alertmanager交互的配置参数;每个Alertmanager可通过静态配置(static_configs)直接给出定义,也可基于Prometheus⽀持的服务发现机制进⾏⾃动配置;' A  s- u/ R# J$ o
    4.remote_write:& W( j( Y! y4 r4 j* `
        配置"远程写"机制,Prometheus需要将数据保存于外部的存储系统(例如InfluxDB)时定义此配置段,随后Prometheus将样本数据通过HTTP协议发送给由URL指定适配器(Adaptor);. ]2 X  A! X( G9 L5 @) I. j; c% D' |
    5.remote_read:  Z. E5 p/ P: |7 M
        配置"远程读"机制,Prometheus将接收到的查询请求交给由URL指定适配器(Adpater)执⾏,Adapter将请求条件转换为远程存储服务中的查询请求,并将获取的响应数据转换为Prometheus可⽤的格式
3 ^8 K; T! s; d( X3 V    2.1.scrape配置段
4 e* Q+ [. z( }% {8 Y( _        1.使⽤static_configs静态配置Job的语法格式:, Q% d+ v" b8 s6 M5 W) f/ `
            # The targets specified by the static config.6 `. p1 _0 p6 |5 F  v# ~
            targets:( A/ f* Q+ c# H1 S9 |4 r
              [ - '<host>' ]
5 ], q6 D! ?* ]8 l            # Labels assigned to all metrics scraped from the targets.0 C* [0 |1 B& L  Y* l& C4 R
            labels:
% ]# z$ `/ ]& ]0 T; K" A              [ <labelname>: <labelvalue> ... ]
8 `$ {+ j& F1 h+ G6 e& H9 N" d+ k4 J        2.使⽤file_sd_configs基于文件发现机制配置Job的语法格式5 }: X3 H8 b# H* O/ J7 n
            [
, {2 K) G$ V# Z' y' J! k" N                {
! ?$ `% k+ T- C8 r4 J                    "targets": [ "<host>", ... ],  |! Z) T6 p( X2 N+ ]* \
                    "labels": {
% q& E) X! M4 Q6 i) {1 B$ @                      "<labelname>": "<labelvalue>", ...
" h" z  Q- |4 U                    }! s1 x6 c$ a% W7 W
                },
) o9 K0 s, ?4 A9 |                ...* X0 ]" F* ~/ p
            ]# c( L: q0 k2 R
3.5.配置prometheus监控ceph集群和ceph存储节点主机3 h8 x: c  B' Y# H
    ~]# vim /etc/prometheus/prometheus.yml
3 b) v# n* l2 m' @& ~# l, L, w% H7 L        scrape_configs:' \) w) _8 G1 }$ c3 i. u
          - job_name: 'prometheus'
2 R9 B5 l, b: r. Z. s8 z! h            static_configs:! G% Z. m- n. Y$ V) N. ^8 I
            - targets: ['111.231.143.40:9090']
/ V" p$ `/ l3 y# S8 d          - job_name: 'node_exporter'
2 i- R4 j# W1 ?5 a  z# F            static_configs:
/ r6 i% i# f: i) {6 j; b            - targets: ['stor01.cre.io:9100']
- ^3 [# `  \6 V5 T3 K            - targets: ['stor02.cre.io:9100']+ W& @3 \4 P: b5 x- b
            - targets: ['stor03.cre.io:9100']9 [6 G+ N2 ~5 q* @0 [
          - job_name: 'ceph'. V+ i. X7 }8 p+ O% D- w
        #   honor_labels: true7 ~- s4 J; f+ c0 [0 t0 c/ i6 T/ }
            static_configs:
& T9 H# |$ f* N4 N            - targets: ['stor02.cre.io:9283']6 R# ]* C% l3 }8 g$ X
    注意事项:& b; L: [" E9 W7 |
        1.job_name=node_exporter设置ceph集群的3个主机节点,job_name=ceph设置manager所在节点的主机名和Prometheus模块的端口;2 s  M' Y1 o  q0 e
        2.注意prometheus中的targets中要写主机的FQDN格式的主机名,否者ceph dashboard中host details中不能正常显示监控数据,因为ceph dashboard是使用FQDN格式的主机名查询监控信息,如果prometheus中写的是IP会导致查询不到;而grafana使用IP查询,所以在grafana中不会有这种错误;( z- N* V+ M0 X9 P1 {3 Z0 g
        3.honor_labels=true必须有且设置为true,否者会导致CephDashbaord中显示grafana某些面板没有数据出现(这个待验证,个人认为可以设置此参数);# b1 Q# N0 I- q. q- K0 t7 B
        4.如果ceph集群中部署了多个manager,需要在job_name=ceph中添加多个targets将所有magr的地址都写上;(本ceph集群只部署了一个mgr)6 k, N! i0 A. E( A2 J! K- y: X
~]# systemctl daemon-reload& V! f; Q5 }) j; J$ u% @
~]# systemctl start prometheus && systemctl enable prometheus  #设置开启自启
- y. N1 W% \: H: }* E: F, A9 B验证配置是否抓取到数据:0 l5 J* r& t+ n4 Y( K$ {9 f: d- X) w
    登录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进行间接采集;3 m# M% r/ D9 t
2.mgr的prometheus_exporter和node_exporter
. O. C) d% ?  S    1.由于Ceph底层是rados协议没有http接口,所以也需要有单独的exporter进行采集,只需要在ceph的一个节点上安装prometheus_exporter,获得cephX授权后通过mon或mgr查询ceph集群信息后,把采集到的数据转为与prometheus兼容的格式并通过http协议响应prometheus的拉取请求;好在这个prometheus_exporter是直接内置在Ceph的mgr模块中的,只需要启用该模块即可;* C* a0 ~) U4 G7 i$ E8 o
    2.由于mgr内嵌的prometheus_exporter只是监控Ceph系统本身的数据,而每个ceph节点主机的cpu、内存信息还是需要部署node_exporter进行数据采集监控的;8 h1 ^( ~6 a% _( D
3.1.创建运⾏Prometheus Server进程的系统⽤⼾,并为其创建家⽬录/var/lib/prometheus作为数据存储⽬录;如果公司内部中已有prometheus,可省略下面部分的安装过程,直接进行监控ceph的配置部分即可;+ a9 z* _4 g. H: A$ q
    ~]# useradd -r -m -d /var/lib/prometheus prometheus  #创建数据目录- x% q* H9 P7 B) G4 C0 c9 Z" I
    ~]# tar xf prometheus-2.7.2.linux-amd64.tar.gz -C /usr/local/4 ~2 B% [' i+ W( D9 T8 b, R0 e
        #官方下载二进制包解压0 Z$ Q7 U/ B+ p" f  x6 G
    ~]# ln /usr/local/prometheus-2.7.2.linux-amd64 /usr/local/prometheus* K9 S8 g+ B% v) m* L& l  }
        #创建软链接
+ a1 o* T! F3 i' c7 w4 V    ~]# prometheus --version    #查看prometheus版本
# O8 Z8 g+ ~  N; L+ v    创建Prometheus专⽤的Unit File文件放在/usr/lib/systemd/system/目录下
# o5 ~4 _/ l, U        ~]# vim /usr/lib/systemd/system/prometheus.service! u8 Q$ E$ O4 Y2 ~! W: T6 V
            [Unit]. H# D9 h- \) N& m: s5 p5 H$ B
            Documentation=https://prometheus.io4 _; \" A5 T/ h9 t2 ]
            After=network.target
, S/ T# j2 q6 Q$ @0 W& w% J  }            [Service]
- W( o" t+ m" o7 j; G            EnvironmentFile=-/etc/sysconfig/prometheus
7 W! d9 K% Z8 U            User=prometheus  j% b2 U$ r9 v4 _4 ^- W
            ExecStart=/usr/local/prometheus/prometheus \# {. w& P( l: V! k
                    --storage.tsdb.path=/var/lib/prometheus \
8 n" j( \2 O8 r5 H2 C! B                    --config.file=/usr/local/prometheus/prometheus.yml \
& l* R' Z+ l! r/ A& j. f) O                    --web.listen-address=0.0.0.0:9090 \
& y" w. e, S" O% h+ y                    --web.external-url=5 ]  u9 S0 H5 k" }. B
            Restart=on-failure$ _+ `* ^9 ^* w
            StartLimitInterval=1
1 _: p( ~8 w0 X- W# `# q            RestartSec=3
5 V& h3 n7 R2 Y' O1 M            [Install]
. `( S% j% w/ J            WantedBy=multi-user.target
' y' e4 V2 S5 `+ V1 K3.2.每个Ceph节点安装node_exporter采集ceph节点主机的数据
7 _* \$ s( V& H  o2 `7 B+ p    ~]# tar xf node_exporter-0.17.0.linux-amd64.tar.gz -C /usr/local/ 8 }6 g4 f9 {; N2 s
    ~]# ln -sv /usr/local/node_exporter-0.17.0.linux-amd64 /usr/local/node_exporte/ l! P. y' T! p6 {9 i
    ~]# useradd -r -m -d /var/lib/prometheus prometheus
/ f/ E; W( U  B) k) U' {- {        创建运⾏Prometheus Server进程的系统⽤⼾,并为其创建家⽬录/var/lib/prometheus作为数据存储⽬录1 ^# p' C7 f0 y6 ?7 y0 }
    ~]# vim /usr/lib/systemd/system/node_exporter.service$ S3 e7 v* ?+ \# F& G9 s
        [Unit]
4 ]- Y7 w2 j" b" K        Documentation=https://github.com/prometheus/node_exporter4 K7 L6 P2 \: i, Q2 d  x$ K
        After=network.target* w4 q% N- v! y& P  D; j
        [Service]
; J! Q  Y* X5 E7 l$ y7 y        EnvironmentFile=-/etc/sysconfig/node_exporter
. e' s5 C1 a8 m  [' T7 A  ~        User=prometheus& m/ q* q3 B' w. @8 b. f
        ExecStart=/usr/local/node_exporter/node_exporter \
+ x* V% Q. g, ?" u: ~            $NODE_EXPORTER_OPTS! _; K8 q% H7 ]; |9 I# @% C$ J+ h$ U
        Restart=on-failure% t) V" Q, _' g
        StartLimitInterval=1
# g5 `6 P5 C( ^, v/ m; [# t        RestartSec=3
; Z/ u( z5 e+ E9 _$ j- @        [Install]4 y9 Y: |5 |! ?, g+ e6 _+ @) Y7 d( d
        WantedBy=multi-user.target
# a: }& r+ R8 Z    ~]# systemctl daemon-reload && systemctl start node_exporter.service) C1 G1 v/ w* n6 n
    ~]# s -tunpl |grep 9100      #查看监控端口
9 v: Z# f$ o) y( S1 _        tcp    LISTEN     0      128      :::9100     :::*   users:(("node_exporter",pid=6776,fd=3))
7 J7 h4 k( T, ?' P5 a  }    ~]# curl localhost:9100/metrics  #测试会否采集到指标数据% i; K% _8 Z! [, E
3.3.启用Ceph-mgr中的promethues模块: P, `+ T; \6 ^$ l( X
    ~]# ceph mgr module enable prometheus9 S9 G8 f) v" I1 Y. r( [
        #Prometheus模块默认监听于TCP协议的9283端⼝( B- q) p" ^( O1 E
    ~]# ceph mgr services7 n2 e7 N' O( W0 z% e; n
        {
- W, k; }/ p- H( \" M: H# a9 z* ?            "dashboard": "http://stor02.cre.io:8080/",
- Y) i0 f: y0 U* H& f            "prometheus": "http://stor02.cre.io:9283/"5 X' [, \3 W( @/ Z$ H% }0 R9 B5 D
        }/ O# d9 r# F+ D
    ~]# ss -tunpl |grep 9283, }  p9 o! S/ K. _  j9 x: G
        tcp    LISTEN     0      5        :::9283      :::*    users:(("ceph-mgr",pid=1071,fd=22))
" c* c9 T% t, N8 ]) ?/ G% M        #会在Mgr所在的存储节点上开启9283端口/ Q( C+ ^  [3 H& z, U' t
3.4.Prometheus的主配置⽂件为prometheus.yml字段和格式解释
3 H7 h+ ?* {3 ^- ?+ f6 ]5 c    prometheus.yml文件主要由global、rule_files、scrape_configs、alerting、remote_write和remote_read⼏个配置段组成,其中:
' o, V* g" D: b/ q    1.global:全局配置段;4 l  E, E4 }, S" q* L5 S/ @$ n$ z4 Q
    2.scrape_configs:配置要监控的目标对象
* o, F, V3 X- }" A: v  @/ `        scrape配置集合,⽤于定义监控的⽬标对象(target)的集合,以及描述如何抓取(scrape)相关指标数据的配置参数;通常,每个scrape配置对应于⼀个单独的作业(job),⽽每个targets可通过静态配置(static_configs)直接给出定义,也可基于Prometheus⽀持的服务发现机制进⾏⾃动配置;! r" r0 M* H7 X, ~1 e
    3.alertmanager_configs:指定配置监控的报警规则4 ]% h2 _, L: |) }
        可由Prometheus使⽤的Alertmanager实例的集合,以及如何同这些Alertmanager交互的配置参数;每个Alertmanager可通过静态配置(static_configs)直接给出定义,也可基于Prometheus⽀持的服务发现机制进⾏⾃动配置;6 z$ z5 z: e5 X
    4.remote_write:' q  ]" Q) R& p- a' p8 s. u+ y
        配置"远程写"机制,Prometheus需要将数据保存于外部的存储系统(例如InfluxDB)时定义此配置段,随后Prometheus将样本数据通过HTTP协议发送给由URL指定适配器(Adaptor);
# s/ I3 a6 u& V( F& U    5.remote_read:5 b/ g+ ^% `7 k4 s
        配置"远程读"机制,Prometheus将接收到的查询请求交给由URL指定适配器(Adpater)执⾏,Adapter将请求条件转换为远程存储服务中的查询请求,并将获取的响应数据转换为Prometheus可⽤的格式( U# }8 @' x9 P
    2.1.scrape配置段. k7 D; b% Y$ \, R. P
        1.使⽤static_configs静态配置Job的语法格式:( L' T* M8 e- ^; C6 H
            # The targets specified by the static config.: ~0 o3 M9 m1 L' m' U" Z
            targets:' W1 p5 k9 b9 C, W( D$ v% P! ]
              [ - '<host>' ]* Y5 `3 G( _/ ?
            # Labels assigned to all metrics scraped from the targets.+ T" W3 D3 E# Y; }" l! v( B; c
            labels:6 y; \$ [6 q5 A9 g
              [ <labelname>: <labelvalue> ... ]
: ~) \/ k( S: }  @7 `        2.使⽤file_sd_configs基于文件发现机制配置Job的语法格式
* P/ n! C5 e9 g2 I' q' ~            [" k& b# D5 H# u  ^
                {  f& p) B5 i6 d7 R8 r3 r
                    "targets": [ "<host>", ... ],
+ `* S, h- p$ G: w/ e: ]* y                    "labels": {2 J. a( ?# E: U. T
                      "<labelname>": "<labelvalue>", ...
6 Q1 y7 A" l6 F/ H% ]2 H                    }1 k; j- z( X, I* e' x: u
                },
8 N* C8 b4 X) |3 X                ...
  q+ u' n, y! j7 w! I, }. h            ]2 D. [. q* \% ]4 _$ _6 J5 [
3.5.配置prometheus监控ceph集群和ceph存储节点主机
6 x' g, |7 n; H0 v8 E' u" }- v    ~]# vim /etc/prometheus/prometheus.yml; ^! n3 C2 S0 l
        scrape_configs:' A; T: I5 T1 d0 w0 n9 m
          - job_name: 'prometheus'
# D" `) b# X0 R% \            static_configs:5 E! D; }& }& `
            - targets: ['111.231.143.40:9090']
) U' X$ F/ m3 o2 }( e' M          - job_name: 'node_exporter'
% l  N; i) d" O% s3 b6 c- @: B            static_configs:6 E  a  }& y) h
            - targets: ['stor01.cre.io:9100']
+ J& S+ |) x% K" O! h2 @- E            - targets: ['stor02.cre.io:9100']
3 i/ Q% A- S) ?0 b, X            - targets: ['stor03.cre.io:9100']  Q5 s1 u9 P/ c$ X$ v5 h3 {' m' D7 _
          - job_name: 'ceph'
0 \/ A2 {7 M- }9 b5 }        #   honor_labels: true9 l( u, M0 Z, f
            static_configs:
0 U7 y# c5 T# ?# Z2 W            - targets: ['stor02.cre.io:9283']% {  e- l8 [! z2 D
    注意事项:
4 X" y- s6 T9 g        1.job_name=node_exporter设置ceph集群的3个主机节点,job_name=ceph设置manager所在节点的主机名和Prometheus模块的端口;
3 G+ `2 Y; i$ d9 V+ V2 u) d8 }        2.注意prometheus中的targets中要写主机的FQDN格式的主机名,否者ceph dashboard中host details中不能正常显示监控数据,因为ceph dashboard是使用FQDN格式的主机名查询监控信息,如果prometheus中写的是IP会导致查询不到;而grafana使用IP查询,所以在grafana中不会有这种错误;
9 {+ r5 ~# C$ J* I+ B) M        3.honor_labels=true必须有且设置为true,否者会导致CephDashbaord中显示grafana某些面板没有数据出现(这个待验证,个人认为可以设置此参数);
7 Q) C3 e) h& V0 G* \# a# n" @        4.如果ceph集群中部署了多个manager,需要在job_name=ceph中添加多个targets将所有magr的地址都写上;(本ceph集群只部署了一个mgr)8 ]' S  c& ^' @+ O
~]# systemctl daemon-reload
: n7 v) j( ?, R+ I) V: Z9 X: p~]# systemctl start prometheus && systemctl enable prometheus  #设置开启自启
  R7 u& X! }, R5 ]7 Y验证配置是否抓取到数据:
/ p+ x/ B- w' R    登录prometheus地址:http://192.168.10.10:9090,查看Targets页面上的prometheus、3个node、ceph mgr是否都是UP的即可:
; m3 p# k' P$ H0 t) |' D2 K
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 03:22 , Processed in 0.016935 second(s), 23 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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