Ceph/Prometheus をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
cephの構成員osd HDDの管理は常時必要. 異常がでたら関知して...
Prometheus: データの収集と蓄積を担う
-HDDの空き容量、読み書きのIOPS, エラーレート、OSDのUp/Dow...
-node-exporterを使えばCPU使用率、メモリ残量、ディスクIO、...
Alertmanager: 通知の判断と配送役
-アラートを整理して無制限にメールを飛ばさない
-Sloackやメールに通知
PrometheusとAlertmanagerは共にcephからデプロイされます
まずはAlertmanagerを構築して、Gmailへテストメールが飛ぶこ...
***Alertmanagerの構築 [#sbf6d378]
Alertmanagerはコンテナとして用意されています。
#code(nonumber){{
[root@ceph-mgr ~]# ceph orch apply alertmanager --placeme...
:
####################
SERVICESPEC PREVIEWS
####################
+--------------+--------------+----------+-------------+
|SERVICE |NAME |ADD_TO |REMOVE_FROM |
+--------------+--------------+----------+-------------+
|alertmanager |alertmanager |ceph-mgr | |
+--------------+--------------+----------+-------------+
:
[root@ceph-mgr ~]# ceph orch apply alertmanager --placeme...
[root@ceph-mgr ~]# ceph orch ls alertmanager
NAME PORTS RUNNING REFRESHED AGE PLACE...
alertmanager ?:9093,9094 1/1 74s ago 97s ceph-...
[root@ceph-mgr ~]# ceph orch ps ceph-mgr
NAME HOST PORTS STATUS ...
alertmanager.ceph-mgr ceph-mgr *:9093,9094 running (98...
crash.ceph-mgr ceph-mgr running (45...
mgr.ceph-mgr.nwgopq ceph-mgr *:8443,8765 running (45...
[root@ceph-mgr ~]#
}}
次にメール設定を行います
#code(nonumber){{
[root@ceph-mgr ~]# cat alertmanager.yml
global:
smtp_smarthost: 'smtp.gmail.com:587'
smtp_from: 'xxxxxxxxxxxxxxxxxxxxxxxx@gmail.com'
smtp_auth_username: 'xxxxxxxxxxxxxxxxxxxxxxxx@gmail.com'
smtp_auth_password: 'aaaabbbbccccdddd'
smtp_require_tls: true
route:
receiver: 'gmail-notice'
group_by: ['alertname']
group_wait: 30s
group_interval: 5m
repeat_interval: 3h
receivers:
- name: 'gmail-notice'
email_configs:
- to: 'xxxxxxxxxxxxxxxxxxxxxxxx@gmail.com'
send_resolved: true
[root@ceph-mgr ~]# ceph config-key set mgr/cephadm/servic...
[root@ceph-mgr ~]# ceph orch redeploy alertmanager
(確認)
[root@ceph-mgr ~]# curl -s http://localhost:9093/api/v2/s...
}}
テストメールを投じてみます. ceph-mgrにて
#code(nonumber){{
[root@ceph-mgr ~]# curl -X POST http://localhost:9093/api...
-H "Content-Type: application/json" \
-d '[
{
"labels": {
"alertname": "TestAlert",
"severity": "critical"
},
"annotations": {
"summary": "Alertmanager mail test 1st",
"description": "manual test"
},
"generatorURL": "http://localhost/test",
"startsAt": "'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'",
"endsAt": "'$(date -u -d "+10 minutes" +"%Y-%m-%dT%...
}
]'
[root@ceph-mgr ~]#
}}
通信設定が上手く行ってれば、下記のようなGmailが届きます
&ref(2026y05m06d_020054902.png,nolink,70%);
***Prometheus の構築 [#d297b151]
Alertmanagerと同様にコンテナで動きます
#code(nonumber){{
[root@ceph-mgr ~]# ceph orch apply prometheus --placement...
:
####################
SERVICESPEC PREVIEWS
####################
+------------+------------+----------+-------------+
|SERVICE |NAME |ADD_TO |REMOVE_FROM |
+------------+------------+----------+-------------+
|prometheus |prometheus |ceph-mgr | |
+------------+------------+----------+-------------+
:
[root@ceph-mgr ~]# ceph orch apply prometheus --placement...
[root@ceph-mgr ~]# ceph orch ps ceph-mgr
NAME HOST PORTS STATUS ...
alertmanager.ceph-mgr ceph-mgr *:9093,9094 running (15...
crash.ceph-mgr ceph-mgr running (83...
mgr.ceph-mgr.nwgopq ceph-mgr *:8443,8765 running (83...
prometheus.ceph-mgr ceph-mgr *:9095 running (3m...
[root@ceph-mgr ~]# ceph orch ls prometheus
NAME PORTS RUNNING REFRESHED AGE PLACEMENT
prometheus ?:9095 1/1 3m ago 4m ceph-mgr
[root@ceph-mgr ~]#
}}
どのような状態になれば Alertmanager に通知を依頼するかはP...
その内容は http://ceph-mgr:9095 の上部メニュー「Status」-...
&ref(2026y05m06d_103515724.png,nolink,70%);
あるいは prometheus のコンテナ内の/etc/prometheus/alertin...
ここでは cintainer idが「4e9a9ce8ec2d」なので
#code(nonumber){{
[root@ceph-mgr ~]# podman exec -it 4e9a9ce8ec2d cat /etc/...
}}
で閲覧できる.
***ハード障害を起こしてみる [#od11cc2a]
こちらは仮想マシンなのでいくらやっても大丈夫ですが、本番...
osd hddの1つを停止してみる
#code(nonumber){{
[root@ceph-mgr ~]# ceph orch daemon stop osd.1
Scheduled to stop osd.1 on host 'ceph-osd01'
[root@ceph-mgr ~]#
[root@ceph-mgr ~]# ceph osd tree
ID CLASS WEIGHT TYPE NAME STATUS REWEIGH...
-1 0.29279 root default
-3 0.09760 host ceph-osd01
1 hdd 0.04880 osd.1 down 1.0000...
0 ssd 0.04880 osd.0 up 1.0000...
-7 0.09760 host ceph-osd02
3 hdd 0.04880 osd.3 up 1.0000...
2 ssd 0.04880 osd.2 up 1.0000...
-10 0.09760 host ceph-osd03
5 hdd 0.04880 osd.5 up 1.0000...
4 ssd 0.04880 osd.4 up 1.0000...
[root@ceph-mgr ~]#
[root@ceph-mgr ~]# ceph health
HEALTH_WARN 1 osds down; Degraded data redundancy: 8/90 o...
[root@ceph-mgr ~]#
}}
っでメールが届く
&ref(2026y05m06d_200205433.png,nolink,70%); &ref(2026y05m...
っで復旧させてみる
#code(nonumber){{
[root@ceph-mgr ~]# ceph orch daemon start osd.1
Scheduled to start osd.1 on host 'ceph-osd01'
[root@ceph-mgr ~]#
}}
っでメールが届く
&ref(2026y05m06d_202802936.png,nolink,70%); &ref(2026y05m...
***slackでも受け取りたい場合 [#c6f17f1a]
#code(nonumber){{
[root@ceph-mgr ~]# cat alertmanager.yml
global:
smtp_smarthost: 'smtp.gmail.com:587'
smtp_from: 'xxxxxxxxxxxxxxxxxxxxxxxx@gmail.com'
smtp_auth_username: 'xxxxxxxxxxxxxxxxxxxxxxxx@gmail.com'
smtp_auth_password: 'aaaabbbbccccdddd'
smtp_require_tls: true
route:
group_by: ['alertname']
group_wait: 30s
group_interval: 5m
repeat_interval: 3h
receiver: 'gmail-slack-notice'
receivers:
- name: 'gmail-slack-notice'
email_configs:
- to: 'xxxxxxxxxxxxxxxxxxxxxxxx@gmail.com'
send_resolved: true
slack_configs:
- api_url: 'https://hooks.slack.com/services/AAAAAA...
channel: '#ceph-alerts'
send_resolved: true
title: 'Ceph Alert'
text: 'Ceph alert detected'
[root@ceph-mgr ~]#
[root@ceph-mgr ~]# ceph config-key set mgr/cephadm/servic...
[root@ceph-mgr ~]# ceph orch redeploy alertmanager
(確認)
[root@ceph-mgr ~]# ceph config-key get mgr/cephadm/servic...
}}
これでslackにも通知が届きます
slackでの「api_url」の値ですが、
slackの「チャンネル」欄の「+」から「チェンネルを作成する...
&ref(2026y05m11d_143138428.png,nolink);
ここでは「#ceph-alert」を作ります
&ref(2026y05m08d_040034196.png,nolink);
すると「チャンネル」欄に「#ceph-alrt」が表示されます
&ref(2026y05m11d_143500400.png,nolink);
次に、「https://api.slack.com/apps」にアクセスして(認証が...
下記画面が表示されたら「Create an App」をクリックします
&ref(2026y05m08d_041720877.png,nolink,80%);
下記画面が表示されて、「From scratch」を押下します
&ref(2026y05m08d_041733813.png,nolink);
appの名称を入れます。あとworkspaceを選択します。
ここではappの名称は「ceph-alerts」にしてます。「Create Ap...
&ref(2026y05m08d_041914428.png,nolink);
作られた「ceph-alerts」アプリの設定画面が表示され、左縦メ...
表示された「Incoming Webhooks」画面で、「Active Incoming ...
&ref(2026y05m08d_042051420.png,nolink,70%);
作ったAppをチャンネルにアサインします
&ref(2026y05m08d_042123908.png,nolink,80%);
すると Webhook 向けのURLが用意されます。「Webhook URL」欄...
&ref(2026y05m08d_042140435.png,nolink,80%);
「Sample curl request to post to channel:」にある文字列は...
終了行:
cephの構成員osd HDDの管理は常時必要. 異常がでたら関知して...
Prometheus: データの収集と蓄積を担う
-HDDの空き容量、読み書きのIOPS, エラーレート、OSDのUp/Dow...
-node-exporterを使えばCPU使用率、メモリ残量、ディスクIO、...
Alertmanager: 通知の判断と配送役
-アラートを整理して無制限にメールを飛ばさない
-Sloackやメールに通知
PrometheusとAlertmanagerは共にcephからデプロイされます
まずはAlertmanagerを構築して、Gmailへテストメールが飛ぶこ...
***Alertmanagerの構築 [#sbf6d378]
Alertmanagerはコンテナとして用意されています。
#code(nonumber){{
[root@ceph-mgr ~]# ceph orch apply alertmanager --placeme...
:
####################
SERVICESPEC PREVIEWS
####################
+--------------+--------------+----------+-------------+
|SERVICE |NAME |ADD_TO |REMOVE_FROM |
+--------------+--------------+----------+-------------+
|alertmanager |alertmanager |ceph-mgr | |
+--------------+--------------+----------+-------------+
:
[root@ceph-mgr ~]# ceph orch apply alertmanager --placeme...
[root@ceph-mgr ~]# ceph orch ls alertmanager
NAME PORTS RUNNING REFRESHED AGE PLACE...
alertmanager ?:9093,9094 1/1 74s ago 97s ceph-...
[root@ceph-mgr ~]# ceph orch ps ceph-mgr
NAME HOST PORTS STATUS ...
alertmanager.ceph-mgr ceph-mgr *:9093,9094 running (98...
crash.ceph-mgr ceph-mgr running (45...
mgr.ceph-mgr.nwgopq ceph-mgr *:8443,8765 running (45...
[root@ceph-mgr ~]#
}}
次にメール設定を行います
#code(nonumber){{
[root@ceph-mgr ~]# cat alertmanager.yml
global:
smtp_smarthost: 'smtp.gmail.com:587'
smtp_from: 'xxxxxxxxxxxxxxxxxxxxxxxx@gmail.com'
smtp_auth_username: 'xxxxxxxxxxxxxxxxxxxxxxxx@gmail.com'
smtp_auth_password: 'aaaabbbbccccdddd'
smtp_require_tls: true
route:
receiver: 'gmail-notice'
group_by: ['alertname']
group_wait: 30s
group_interval: 5m
repeat_interval: 3h
receivers:
- name: 'gmail-notice'
email_configs:
- to: 'xxxxxxxxxxxxxxxxxxxxxxxx@gmail.com'
send_resolved: true
[root@ceph-mgr ~]# ceph config-key set mgr/cephadm/servic...
[root@ceph-mgr ~]# ceph orch redeploy alertmanager
(確認)
[root@ceph-mgr ~]# curl -s http://localhost:9093/api/v2/s...
}}
テストメールを投じてみます. ceph-mgrにて
#code(nonumber){{
[root@ceph-mgr ~]# curl -X POST http://localhost:9093/api...
-H "Content-Type: application/json" \
-d '[
{
"labels": {
"alertname": "TestAlert",
"severity": "critical"
},
"annotations": {
"summary": "Alertmanager mail test 1st",
"description": "manual test"
},
"generatorURL": "http://localhost/test",
"startsAt": "'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'",
"endsAt": "'$(date -u -d "+10 minutes" +"%Y-%m-%dT%...
}
]'
[root@ceph-mgr ~]#
}}
通信設定が上手く行ってれば、下記のようなGmailが届きます
&ref(2026y05m06d_020054902.png,nolink,70%);
***Prometheus の構築 [#d297b151]
Alertmanagerと同様にコンテナで動きます
#code(nonumber){{
[root@ceph-mgr ~]# ceph orch apply prometheus --placement...
:
####################
SERVICESPEC PREVIEWS
####################
+------------+------------+----------+-------------+
|SERVICE |NAME |ADD_TO |REMOVE_FROM |
+------------+------------+----------+-------------+
|prometheus |prometheus |ceph-mgr | |
+------------+------------+----------+-------------+
:
[root@ceph-mgr ~]# ceph orch apply prometheus --placement...
[root@ceph-mgr ~]# ceph orch ps ceph-mgr
NAME HOST PORTS STATUS ...
alertmanager.ceph-mgr ceph-mgr *:9093,9094 running (15...
crash.ceph-mgr ceph-mgr running (83...
mgr.ceph-mgr.nwgopq ceph-mgr *:8443,8765 running (83...
prometheus.ceph-mgr ceph-mgr *:9095 running (3m...
[root@ceph-mgr ~]# ceph orch ls prometheus
NAME PORTS RUNNING REFRESHED AGE PLACEMENT
prometheus ?:9095 1/1 3m ago 4m ceph-mgr
[root@ceph-mgr ~]#
}}
どのような状態になれば Alertmanager に通知を依頼するかはP...
その内容は http://ceph-mgr:9095 の上部メニュー「Status」-...
&ref(2026y05m06d_103515724.png,nolink,70%);
あるいは prometheus のコンテナ内の/etc/prometheus/alertin...
ここでは cintainer idが「4e9a9ce8ec2d」なので
#code(nonumber){{
[root@ceph-mgr ~]# podman exec -it 4e9a9ce8ec2d cat /etc/...
}}
で閲覧できる.
***ハード障害を起こしてみる [#od11cc2a]
こちらは仮想マシンなのでいくらやっても大丈夫ですが、本番...
osd hddの1つを停止してみる
#code(nonumber){{
[root@ceph-mgr ~]# ceph orch daemon stop osd.1
Scheduled to stop osd.1 on host 'ceph-osd01'
[root@ceph-mgr ~]#
[root@ceph-mgr ~]# ceph osd tree
ID CLASS WEIGHT TYPE NAME STATUS REWEIGH...
-1 0.29279 root default
-3 0.09760 host ceph-osd01
1 hdd 0.04880 osd.1 down 1.0000...
0 ssd 0.04880 osd.0 up 1.0000...
-7 0.09760 host ceph-osd02
3 hdd 0.04880 osd.3 up 1.0000...
2 ssd 0.04880 osd.2 up 1.0000...
-10 0.09760 host ceph-osd03
5 hdd 0.04880 osd.5 up 1.0000...
4 ssd 0.04880 osd.4 up 1.0000...
[root@ceph-mgr ~]#
[root@ceph-mgr ~]# ceph health
HEALTH_WARN 1 osds down; Degraded data redundancy: 8/90 o...
[root@ceph-mgr ~]#
}}
っでメールが届く
&ref(2026y05m06d_200205433.png,nolink,70%); &ref(2026y05m...
っで復旧させてみる
#code(nonumber){{
[root@ceph-mgr ~]# ceph orch daemon start osd.1
Scheduled to start osd.1 on host 'ceph-osd01'
[root@ceph-mgr ~]#
}}
っでメールが届く
&ref(2026y05m06d_202802936.png,nolink,70%); &ref(2026y05m...
***slackでも受け取りたい場合 [#c6f17f1a]
#code(nonumber){{
[root@ceph-mgr ~]# cat alertmanager.yml
global:
smtp_smarthost: 'smtp.gmail.com:587'
smtp_from: 'xxxxxxxxxxxxxxxxxxxxxxxx@gmail.com'
smtp_auth_username: 'xxxxxxxxxxxxxxxxxxxxxxxx@gmail.com'
smtp_auth_password: 'aaaabbbbccccdddd'
smtp_require_tls: true
route:
group_by: ['alertname']
group_wait: 30s
group_interval: 5m
repeat_interval: 3h
receiver: 'gmail-slack-notice'
receivers:
- name: 'gmail-slack-notice'
email_configs:
- to: 'xxxxxxxxxxxxxxxxxxxxxxxx@gmail.com'
send_resolved: true
slack_configs:
- api_url: 'https://hooks.slack.com/services/AAAAAA...
channel: '#ceph-alerts'
send_resolved: true
title: 'Ceph Alert'
text: 'Ceph alert detected'
[root@ceph-mgr ~]#
[root@ceph-mgr ~]# ceph config-key set mgr/cephadm/servic...
[root@ceph-mgr ~]# ceph orch redeploy alertmanager
(確認)
[root@ceph-mgr ~]# ceph config-key get mgr/cephadm/servic...
}}
これでslackにも通知が届きます
slackでの「api_url」の値ですが、
slackの「チャンネル」欄の「+」から「チェンネルを作成する...
&ref(2026y05m11d_143138428.png,nolink);
ここでは「#ceph-alert」を作ります
&ref(2026y05m08d_040034196.png,nolink);
すると「チャンネル」欄に「#ceph-alrt」が表示されます
&ref(2026y05m11d_143500400.png,nolink);
次に、「https://api.slack.com/apps」にアクセスして(認証が...
下記画面が表示されたら「Create an App」をクリックします
&ref(2026y05m08d_041720877.png,nolink,80%);
下記画面が表示されて、「From scratch」を押下します
&ref(2026y05m08d_041733813.png,nolink);
appの名称を入れます。あとworkspaceを選択します。
ここではappの名称は「ceph-alerts」にしてます。「Create Ap...
&ref(2026y05m08d_041914428.png,nolink);
作られた「ceph-alerts」アプリの設定画面が表示され、左縦メ...
表示された「Incoming Webhooks」画面で、「Active Incoming ...
&ref(2026y05m08d_042051420.png,nolink,70%);
作ったAppをチャンネルにアサインします
&ref(2026y05m08d_042123908.png,nolink,80%);
すると Webhook 向けのURLが用意されます。「Webhook URL」欄...
&ref(2026y05m08d_042140435.png,nolink,80%);
「Sample curl request to post to channel:」にある文字列は...
ページ名:
1