找回密码
 注册
查看: 3071|回复: 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进行间接采集;
" l( K$ F8 g% P2 |9 T0 [, s2.mgr的prometheus_exporter和node_exporter4 J% H4 L" L( ?- l5 m% {
    1.由于Ceph底层是rados协议没有http接口,所以也需要有单独的exporter进行采集,只需要在ceph的一个节点上安装prometheus_exporter,获得cephX授权后通过mon或mgr查询ceph集群信息后,把采集到的数据转为与prometheus兼容的格式并通过http协议响应prometheus的拉取请求;好在这个prometheus_exporter是直接内置在Ceph的mgr模块中的,只需要启用该模块即可;) L( l! m$ J( X
    2.由于mgr内嵌的prometheus_exporter只是监控Ceph系统本身的数据,而每个ceph节点主机的cpu、内存信息还是需要部署node_exporter进行数据采集监控的;) F/ l" P6 q5 }, R
3.1.创建运⾏Prometheus Server进程的系统⽤⼾,并为其创建家⽬录/var/lib/prometheus作为数据存储⽬录;如果公司内部中已有prometheus,可省略下面部分的安装过程,直接进行监控ceph的配置部分即可;
  i/ ^# n/ g/ Y1 u    ~]# useradd -r -m -d /var/lib/prometheus prometheus  #创建数据目录
! _0 k, q+ s/ z' j. n    ~]# tar xf prometheus-2.7.2.linux-amd64.tar.gz -C /usr/local/+ c( Y. ]6 O% u0 H1 u
        #官方下载二进制包解压
9 z& w9 ~0 ^7 k! k+ p8 i    ~]# ln /usr/local/prometheus-2.7.2.linux-amd64 /usr/local/prometheus  H" p% v* v1 K
        #创建软链接# v5 }: V. k% p2 V. H5 \  g
    ~]# prometheus --version    #查看prometheus版本6 O; l. u. F# L$ G  f2 R
    创建Prometheus专⽤的Unit File文件放在/usr/lib/systemd/system/目录下7 P" q: g# G9 u. b
        ~]# vim /usr/lib/systemd/system/prometheus.service
" l$ S% W% r  w+ K/ Q- _            [Unit]( \8 R9 k9 w! H; e
            Documentation=https://prometheus.io
* P6 H* e% `  b/ J: u            After=network.target! r+ i6 ?9 ]  r- n$ R9 c! s
            [Service]7 |. i4 Q8 ^$ Y/ M  E9 j* o& n
            EnvironmentFile=-/etc/sysconfig/prometheus
9 b3 Z. B! a0 b! r+ j+ ^            User=prometheus! I# ^  z+ M) E8 v
            ExecStart=/usr/local/prometheus/prometheus \& s# h- F4 e  W' B
                    --storage.tsdb.path=/var/lib/prometheus \
9 A! }4 k3 f4 W# e7 ]                    --config.file=/usr/local/prometheus/prometheus.yml \+ I$ O2 G& C) ^# G
                    --web.listen-address=0.0.0.0:9090 \
! c* u* P% u" v( G                    --web.external-url=
/ e1 ?, n* O' m; z            Restart=on-failure
0 i8 w: b) Z2 ~8 s4 o" j, \            StartLimitInterval=1. w. X3 l) W5 A+ j5 w- |
            RestartSec=3
' j1 t$ }, j& U9 g) e7 E- |5 d: j            [Install], b# ^$ h" @: X$ O9 v
            WantedBy=multi-user.target
0 o# \6 V2 q. p2 i1 R! ~3.2.每个Ceph节点安装node_exporter采集ceph节点主机的数据
# Z$ ]% I6 }/ \6 ]. E; W) R& M% @    ~]# tar xf node_exporter-0.17.0.linux-amd64.tar.gz -C /usr/local/ 9 G! J3 f$ Q! [1 C3 A& J- x
    ~]# ln -sv /usr/local/node_exporter-0.17.0.linux-amd64 /usr/local/node_exporte6 [# e, D( a! d& ]8 f% U
    ~]# useradd -r -m -d /var/lib/prometheus prometheus
: R4 G( G/ z+ K& k5 K! K        创建运⾏Prometheus Server进程的系统⽤⼾,并为其创建家⽬录/var/lib/prometheus作为数据存储⽬录% _8 l* [9 `  O4 L- G1 c, @
    ~]# vim /usr/lib/systemd/system/node_exporter.service$ I7 J+ ]# N6 S: }% b
        [Unit]
; [. u8 i2 z2 z! K" M9 U        Documentation=https://github.com/prometheus/node_exporter
9 Q9 d2 w; `2 K, e. M- G. C. c        After=network.target$ f; W! e+ Q! a2 x2 X: S0 [
        [Service]+ q) t; f* T0 i) f1 }* _$ j# |
        EnvironmentFile=-/etc/sysconfig/node_exporter! i' Y2 X2 S# O" X" J" j5 c
        User=prometheus
' f9 `' D6 k% s8 l0 F0 n        ExecStart=/usr/local/node_exporter/node_exporter \
8 @+ H8 e* g& I, l* J# g: V            $NODE_EXPORTER_OPTS
' Y3 S2 x6 K0 I/ y( X! V        Restart=on-failure; x8 O% }6 k/ ^' W! V
        StartLimitInterval=1. j1 H  [+ Z4 X) [& b
        RestartSec=3
6 \! z% v  B+ n  [! u        [Install]
) d3 p/ M1 q3 ^        WantedBy=multi-user.target
6 s6 n, w1 G. w- R+ a    ~]# systemctl daemon-reload && systemctl start node_exporter.service2 z8 P  N4 J! B3 t, }% f" R, `
    ~]# s -tunpl |grep 9100      #查看监控端口
  ^4 C) S# P: B& y        tcp    LISTEN     0      128      :::9100     :::*   users:(("node_exporter",pid=6776,fd=3)), \0 \! @( f( O9 ~7 Y+ x& C
    ~]# curl localhost:9100/metrics  #测试会否采集到指标数据3 Q  X1 s/ O0 _7 p
3.3.启用Ceph-mgr中的promethues模块% s% @$ ^# N8 F
    ~]# ceph mgr module enable prometheus
9 ^! h0 K% a  p' E/ b        #Prometheus模块默认监听于TCP协议的9283端⼝0 [' X0 w0 z! ?5 ]: E$ |
    ~]# ceph mgr services/ d$ b" j$ L- |, D2 Q
        {# [' T5 ]1 W2 R" w) w& @
            "dashboard": "http://stor02.cre.io:8080/"," A6 ?0 C, {0 ]- M# O6 I
            "prometheus": "http://stor02.cre.io:9283/"2 w7 a( N. T7 v5 `- x( K+ I
        }
% v8 v( T+ ?- b. b8 G# C% `    ~]# ss -tunpl |grep 9283
+ I7 v7 J2 f/ e3 k' b3 G- X/ x        tcp    LISTEN     0      5        :::9283      :::*    users:(("ceph-mgr",pid=1071,fd=22))
/ S. \8 Q, H* I  a4 J7 K7 s9 b        #会在Mgr所在的存储节点上开启9283端口
3 q: N1 _+ z7 D3.4.Prometheus的主配置⽂件为prometheus.yml字段和格式解释
8 b( G7 r# P& u) h    prometheus.yml文件主要由global、rule_files、scrape_configs、alerting、remote_write和remote_read⼏个配置段组成,其中:
, g2 ~! ]; q" B( Y) {    1.global:全局配置段;
, g, F8 M% u/ p- C, J0 \8 ^1 V    2.scrape_configs:配置要监控的目标对象3 d1 f+ X8 A: i$ R* k% ~
        scrape配置集合,⽤于定义监控的⽬标对象(target)的集合,以及描述如何抓取(scrape)相关指标数据的配置参数;通常,每个scrape配置对应于⼀个单独的作业(job),⽽每个targets可通过静态配置(static_configs)直接给出定义,也可基于Prometheus⽀持的服务发现机制进⾏⾃动配置;
/ N, K  T3 H; p  I7 |. I- Y  y    3.alertmanager_configs:指定配置监控的报警规则0 b8 t9 O( l" h. Z# ?0 D
        可由Prometheus使⽤的Alertmanager实例的集合,以及如何同这些Alertmanager交互的配置参数;每个Alertmanager可通过静态配置(static_configs)直接给出定义,也可基于Prometheus⽀持的服务发现机制进⾏⾃动配置;7 q; h7 _$ @! D/ P5 @4 J! X1 `
    4.remote_write:* r" s0 h5 _. _2 T) `
        配置"远程写"机制,Prometheus需要将数据保存于外部的存储系统(例如InfluxDB)时定义此配置段,随后Prometheus将样本数据通过HTTP协议发送给由URL指定适配器(Adaptor);
0 ]$ ~# a  p+ f; L    5.remote_read:
2 i- ]/ d, e: r2 S$ _        配置"远程读"机制,Prometheus将接收到的查询请求交给由URL指定适配器(Adpater)执⾏,Adapter将请求条件转换为远程存储服务中的查询请求,并将获取的响应数据转换为Prometheus可⽤的格式' Q6 e! o  g& a. o, \
    2.1.scrape配置段( Y; E6 i# C8 Z5 g
        1.使⽤static_configs静态配置Job的语法格式:
- j9 g4 ~- D0 |            # The targets specified by the static config.1 k3 M! X& Y+ j: D( k0 t
            targets:
- q- K% ]1 w8 C0 x! f              [ - '<host>' ]
& c& u5 L5 Y/ I, K8 s            # Labels assigned to all metrics scraped from the targets.
5 `; e) R/ A/ b' b! S            labels:
8 `* I* I3 d/ O2 w- C/ D              [ <labelname>: <labelvalue> ... ]* Y1 P, J% P- t6 p; I
        2.使⽤file_sd_configs基于文件发现机制配置Job的语法格式1 y. o& F4 Y  L8 q. U4 A8 }% K
            [
- e. W4 ?( O& T4 G6 k9 y                {, d0 C: K# M  R8 q" D* B2 F
                    "targets": [ "<host>", ... ],
1 Z/ O/ S7 k4 B5 Y                    "labels": {& n* H+ N% k8 f+ [
                      "<labelname>": "<labelvalue>", ...* N4 X3 K/ c3 A( P- p2 n
                    }
3 j  T# r- l0 m0 ~; G                },
) w( g4 g0 B* A9 C                ...- t( c, U) ~6 j/ R8 [
            ]
% L0 q8 _7 t: K3.5.配置prometheus监控ceph集群和ceph存储节点主机
) G. q# A) A6 s4 c+ _    ~]# vim /etc/prometheus/prometheus.yml' D4 a& W6 }5 E# h9 ~- o9 h" |
        scrape_configs:
5 w/ O. l; H1 L: K8 q" \          - job_name: 'prometheus'
& a* [6 q2 P8 l. Q& M4 {4 k8 h            static_configs:; b- X9 H) X1 b% q; h9 _' p/ u
            - targets: ['111.231.143.40:9090']
! W' ]9 I* K8 J1 J1 t& k  z          - job_name: 'node_exporter'
" J7 O3 E: l. B+ [2 k# o( A6 M            static_configs:5 [. e, j( @9 |9 H0 l( Z. H
            - targets: ['stor01.cre.io:9100']
* E; Y7 P+ O3 X9 C: F            - targets: ['stor02.cre.io:9100']: s5 V( M) U9 I; J8 s
            - targets: ['stor03.cre.io:9100']
; c% m/ c: ?6 u/ a7 c7 z8 S          - job_name: 'ceph'3 C1 T* d: u0 p0 p1 ~& n  m
        #   honor_labels: true
; W+ R4 E  x, [0 l4 Z+ f/ Z            static_configs:" G& s6 i# V1 c* E4 z
            - targets: ['stor02.cre.io:9283']
% ~  ~/ e; a4 U- D& n9 q  s! c    注意事项:  {9 d! p6 }3 B# \: v0 U9 a! f7 {
        1.job_name=node_exporter设置ceph集群的3个主机节点,job_name=ceph设置manager所在节点的主机名和Prometheus模块的端口;
/ H) w6 |. F. i. U$ [) z        2.注意prometheus中的targets中要写主机的FQDN格式的主机名,否者ceph dashboard中host details中不能正常显示监控数据,因为ceph dashboard是使用FQDN格式的主机名查询监控信息,如果prometheus中写的是IP会导致查询不到;而grafana使用IP查询,所以在grafana中不会有这种错误;
: r1 n8 K; o4 B  Q! q0 w) \        3.honor_labels=true必须有且设置为true,否者会导致CephDashbaord中显示grafana某些面板没有数据出现(这个待验证,个人认为可以设置此参数);! z' Q1 Z- n0 h) s5 @7 N
        4.如果ceph集群中部署了多个manager,需要在job_name=ceph中添加多个targets将所有magr的地址都写上;(本ceph集群只部署了一个mgr)8 {5 ^3 N4 }8 `. [  E6 o5 [
~]# systemctl daemon-reload
0 O! j* E7 ~$ _+ _) ]9 \( z) i~]# systemctl start prometheus && systemctl enable prometheus  #设置开启自启
5 a4 f" h" e+ _验证配置是否抓取到数据:
# \# X0 M5 c) A0 y/ z. Z5 F    登录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进行间接采集;
1 l9 O9 ]' I7 S. r$ k1 H( R2.mgr的prometheus_exporter和node_exporter- [! V# P6 W) a! p1 ]' X, T: ]
    1.由于Ceph底层是rados协议没有http接口,所以也需要有单独的exporter进行采集,只需要在ceph的一个节点上安装prometheus_exporter,获得cephX授权后通过mon或mgr查询ceph集群信息后,把采集到的数据转为与prometheus兼容的格式并通过http协议响应prometheus的拉取请求;好在这个prometheus_exporter是直接内置在Ceph的mgr模块中的,只需要启用该模块即可;2 ^9 C" @- {8 Q! p3 j3 y' [
    2.由于mgr内嵌的prometheus_exporter只是监控Ceph系统本身的数据,而每个ceph节点主机的cpu、内存信息还是需要部署node_exporter进行数据采集监控的;- S% t1 G$ i5 K
3.1.创建运⾏Prometheus Server进程的系统⽤⼾,并为其创建家⽬录/var/lib/prometheus作为数据存储⽬录;如果公司内部中已有prometheus,可省略下面部分的安装过程,直接进行监控ceph的配置部分即可;
; C* h# U. B- ]$ C5 d    ~]# useradd -r -m -d /var/lib/prometheus prometheus  #创建数据目录# `2 ?8 e# w- I5 h
    ~]# tar xf prometheus-2.7.2.linux-amd64.tar.gz -C /usr/local/
4 p( X  `! w: C& Q        #官方下载二进制包解压' k# l. D# p) L
    ~]# ln /usr/local/prometheus-2.7.2.linux-amd64 /usr/local/prometheus' C5 W! m: u. E
        #创建软链接6 \  i6 T; D5 h4 }/ E/ \
    ~]# prometheus --version    #查看prometheus版本
. ?- L0 {8 F. p0 Z; w    创建Prometheus专⽤的Unit File文件放在/usr/lib/systemd/system/目录下" ^7 a" R: I, G, ^3 _# y  l
        ~]# vim /usr/lib/systemd/system/prometheus.service
2 A9 f* \5 o- I0 A5 X            [Unit]8 H5 V- ]# k7 N' }  Q; M7 Y6 J
            Documentation=https://prometheus.io
* @8 y& Z5 y) z" U            After=network.target
0 \* ^+ `8 H0 s8 u7 y9 ^4 W9 n            [Service]
6 \8 A9 _- }5 ?& h" o            EnvironmentFile=-/etc/sysconfig/prometheus
2 y; J. C4 t" t+ s/ L            User=prometheus+ {2 ^9 e) k! Z7 i
            ExecStart=/usr/local/prometheus/prometheus \
9 N# m  \. e4 P" z3 S                    --storage.tsdb.path=/var/lib/prometheus \
! h$ z# ~  ?7 H0 u$ K! k( |                    --config.file=/usr/local/prometheus/prometheus.yml \1 X0 x- \$ Q3 G2 _% }1 D1 a
                    --web.listen-address=0.0.0.0:9090 \+ m% \5 I9 N$ Q' D$ i) A& E
                    --web.external-url=
6 E, Q% A# X+ q0 g8 e            Restart=on-failure
2 E, ]  D( [' {6 K. [% |- w6 `            StartLimitInterval=1$ ~5 O- K( _! A, f
            RestartSec=3
5 J& i' U3 Q- t% |9 d            [Install]( E' i1 h1 H0 S! \
            WantedBy=multi-user.target0 v+ E) k, ~& ^- U" k
3.2.每个Ceph节点安装node_exporter采集ceph节点主机的数据
& |3 ~6 r9 F- \    ~]# tar xf node_exporter-0.17.0.linux-amd64.tar.gz -C /usr/local/ . {" V. t$ E/ L. l( Q
    ~]# ln -sv /usr/local/node_exporter-0.17.0.linux-amd64 /usr/local/node_exporte
! s1 l# I1 `3 r" B    ~]# useradd -r -m -d /var/lib/prometheus prometheus
% I, z& @7 ?! n        创建运⾏Prometheus Server进程的系统⽤⼾,并为其创建家⽬录/var/lib/prometheus作为数据存储⽬录
) D' C8 i- o. b  A4 l. c    ~]# vim /usr/lib/systemd/system/node_exporter.service
1 P5 L. X7 b- U& _. g4 W* J0 L        [Unit]
: ~' h. ~& h8 K  g        Documentation=https://github.com/prometheus/node_exporter% I; g- M7 V0 t. [# A
        After=network.target
, ^. t; b. l  j3 U& [        [Service]
$ ?& r% T- h; l9 l; t        EnvironmentFile=-/etc/sysconfig/node_exporter3 V9 c! Z" ]. s( y' Z. i" l! V
        User=prometheus
& F5 E! `: [, [& Y5 l$ `7 C        ExecStart=/usr/local/node_exporter/node_exporter \( }7 l2 P+ r8 x/ L3 ^( J8 n: H
            $NODE_EXPORTER_OPTS
: v. ^/ ^8 q! s0 e        Restart=on-failure
9 w4 N' a( X* f        StartLimitInterval=1. q+ k3 N$ ]1 L; Z3 o8 A3 d  ?1 ?5 B7 g
        RestartSec=3: E' o1 o, j3 M
        [Install]  a7 t: r& m7 }. t' [8 p; }
        WantedBy=multi-user.target
3 z0 Q1 W  \/ n    ~]# systemctl daemon-reload && systemctl start node_exporter.service
& L0 O# I1 ~6 K2 q: l    ~]# s -tunpl |grep 9100      #查看监控端口
# Y! e/ q( l! l! J& V/ p        tcp    LISTEN     0      128      :::9100     :::*   users:(("node_exporter",pid=6776,fd=3))+ J$ |; n& @! v" p1 T; ~
    ~]# curl localhost:9100/metrics  #测试会否采集到指标数据
9 ?7 @. s  Z  ~3.3.启用Ceph-mgr中的promethues模块8 H& P, g2 B" v
    ~]# ceph mgr module enable prometheus4 h' P" x0 i# x6 k! h- [+ j- p
        #Prometheus模块默认监听于TCP协议的9283端⼝
' d2 m7 S* D: [. b# {    ~]# ceph mgr services
) w- P7 e2 j. Y1 R        {
# h3 {) P8 Q  @" {3 T) @            "dashboard": "http://stor02.cre.io:8080/",
3 G+ g1 G0 \0 Q4 E$ m# \( k+ o            "prometheus": "http://stor02.cre.io:9283/"2 M$ {' R$ j) \2 z9 _( i
        }
6 S1 U: A% m' |2 C3 [4 ]' e7 m& S    ~]# ss -tunpl |grep 9283& Y9 }& O( a/ E2 s6 t) U' x& x
        tcp    LISTEN     0      5        :::9283      :::*    users:(("ceph-mgr",pid=1071,fd=22))7 V$ e( m' x  V, |8 S
        #会在Mgr所在的存储节点上开启9283端口5 Z/ g# ]  [9 M2 o
3.4.Prometheus的主配置⽂件为prometheus.yml字段和格式解释6 Z6 i  `, t# G
    prometheus.yml文件主要由global、rule_files、scrape_configs、alerting、remote_write和remote_read⼏个配置段组成,其中:
- B$ u$ c6 p4 N1 ~! N    1.global:全局配置段;
4 _( @' l7 W( y+ J" q+ z    2.scrape_configs:配置要监控的目标对象: x( _  a. v* K) _" A" X
        scrape配置集合,⽤于定义监控的⽬标对象(target)的集合,以及描述如何抓取(scrape)相关指标数据的配置参数;通常,每个scrape配置对应于⼀个单独的作业(job),⽽每个targets可通过静态配置(static_configs)直接给出定义,也可基于Prometheus⽀持的服务发现机制进⾏⾃动配置;5 j) t( H! \' `! k/ D, I) B+ s$ ^) E
    3.alertmanager_configs:指定配置监控的报警规则
) a4 O4 b% H9 y9 U! ?        可由Prometheus使⽤的Alertmanager实例的集合,以及如何同这些Alertmanager交互的配置参数;每个Alertmanager可通过静态配置(static_configs)直接给出定义,也可基于Prometheus⽀持的服务发现机制进⾏⾃动配置;
6 M  j8 G, c  D+ O* O: {5 r5 O    4.remote_write:; O9 |. |) l3 M* L* B
        配置"远程写"机制,Prometheus需要将数据保存于外部的存储系统(例如InfluxDB)时定义此配置段,随后Prometheus将样本数据通过HTTP协议发送给由URL指定适配器(Adaptor);
2 d( t5 o* f1 W& `4 @6 q6 j    5.remote_read:
8 }( m5 T/ d/ b% _        配置"远程读"机制,Prometheus将接收到的查询请求交给由URL指定适配器(Adpater)执⾏,Adapter将请求条件转换为远程存储服务中的查询请求,并将获取的响应数据转换为Prometheus可⽤的格式
  e( ]+ g1 K& k3 W    2.1.scrape配置段
/ k8 p4 c1 z" w4 |9 I        1.使⽤static_configs静态配置Job的语法格式:9 }7 y: _0 W0 r9 {
            # The targets specified by the static config.  L4 m' U5 W. q( |2 B
            targets:. f4 ~0 S. h8 H1 P3 t6 O5 ?. w5 {
              [ - '<host>' ]  t1 U+ N# ]1 n- S. N: U' W7 A% A
            # Labels assigned to all metrics scraped from the targets.$ ^% M" x9 ~4 L1 A
            labels:
" k- x9 y6 z% h+ Y5 V9 z" X              [ <labelname>: <labelvalue> ... ]
9 c. [8 e. z8 r, ~7 I* o- A        2.使⽤file_sd_configs基于文件发现机制配置Job的语法格式
9 n* R7 B7 |" o9 O9 D            [
- Y7 u0 v9 f6 N% u7 ]  o+ l* K                {2 b+ c3 _0 k3 H
                    "targets": [ "<host>", ... ],
& n4 j, {, t) o0 y% a                    "labels": {* \) n' M6 j8 Z" p7 W5 V
                      "<labelname>": "<labelvalue>", ...
6 w; g' B) S9 c5 Q2 Q; g                    }0 ?  t! Q# [& i$ a5 u
                },
$ D. E4 i8 J; G( `) ~- o                ...
  ~9 v3 h, s% b5 {: d            ]# p$ `, ^# b( f! p+ x
3.5.配置prometheus监控ceph集群和ceph存储节点主机
3 s. g: p+ j# T* J) O, g4 @    ~]# vim /etc/prometheus/prometheus.yml8 F6 d  n( {8 o6 z1 K) e
        scrape_configs:: {. s  W" ]. B1 }/ |1 [
          - job_name: 'prometheus'/ a% H/ w( B( `1 ]5 Q, R( @
            static_configs:9 t; z' c+ O6 n4 n9 N
            - targets: ['111.231.143.40:9090']
" J' J$ n& ~; b          - job_name: 'node_exporter'( m. `4 p; @. ?
            static_configs:) z. V! c, [* M1 J1 Z# ?
            - targets: ['stor01.cre.io:9100']2 [. U1 c" y: N
            - targets: ['stor02.cre.io:9100']
4 I/ }) q3 [3 |. [' H, d, F            - targets: ['stor03.cre.io:9100']7 O- H4 Z/ Q$ |+ I8 Y
          - job_name: 'ceph'
# w* A- U, B/ }8 ]$ z        #   honor_labels: true
7 W& x$ e/ d( K4 T# A, k            static_configs:
4 G% O- ~8 U5 u) f* S            - targets: ['stor02.cre.io:9283']/ r/ k1 y3 ^/ K. d- G
    注意事项:6 ?7 {, j) Q' @/ X" W# u* H
        1.job_name=node_exporter设置ceph集群的3个主机节点,job_name=ceph设置manager所在节点的主机名和Prometheus模块的端口;1 k' a$ {2 d& l/ Y2 e
        2.注意prometheus中的targets中要写主机的FQDN格式的主机名,否者ceph dashboard中host details中不能正常显示监控数据,因为ceph dashboard是使用FQDN格式的主机名查询监控信息,如果prometheus中写的是IP会导致查询不到;而grafana使用IP查询,所以在grafana中不会有这种错误;
4 w; q9 k" D$ f* B' [; ~& Q1 }$ S        3.honor_labels=true必须有且设置为true,否者会导致CephDashbaord中显示grafana某些面板没有数据出现(这个待验证,个人认为可以设置此参数);
$ i! d% i* f9 H( K        4.如果ceph集群中部署了多个manager,需要在job_name=ceph中添加多个targets将所有magr的地址都写上;(本ceph集群只部署了一个mgr)( [4 m) r6 K9 t
~]# systemctl daemon-reload
' q8 ~2 H9 c! ?, o~]# systemctl start prometheus && systemctl enable prometheus  #设置开启自启) i! l" J  c6 m* y/ u2 y
验证配置是否抓取到数据:" b' N9 N  q9 z# c. r/ Z- O4 }- f
    登录prometheus地址:http://192.168.10.10:9090,查看Targets页面上的prometheus、3个node、ceph mgr是否都是UP的即可:) ^. s5 R5 z8 u% H/ I  s
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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