cephの構成員osd HDDの管理は常時必要. 異常がでたら関知して、通知する仕組みを入れてみる

Prometheus: データの収集と蓄積を担う

Alertmanager: 通知の判断と配送役

PrometheusとAlertmanagerは共にcephからデプロイされます

まずはAlertmanagerを構築して、Gmailへテストメールが飛ぶことを確認します

Alertmanagerの構築

Alertmanagerはコンテナとして用意されています。

[root@ceph-mgr ~]# ceph orch apply alertmanager --placement="ceph-mgr" --dry-run
 :
####################
SERVICESPEC PREVIEWS
####################
+--------------+--------------+----------+-------------+
|SERVICE       |NAME          |ADD_TO    |REMOVE_FROM  |
+--------------+--------------+----------+-------------+
|alertmanager  |alertmanager  |ceph-mgr  |             |
+--------------+--------------+----------+-------------+
 :
[root@ceph-mgr ~]# ceph orch apply alertmanager --placement="ceph-mgr" 
 
[root@ceph-mgr ~]# ceph orch ls alertmanager
NAME          PORTS        RUNNING  REFRESHED  AGE  PLACEMENT
alertmanager  ?:9093,9094      1/1  74s ago    97s  ceph-mgr
 
[root@ceph-mgr ~]# ceph orch ps ceph-mgr
NAME                   HOST      PORTS        STATUS         REFRESHED   AGE  MEM USE  MEM LIM  VERSION  IMAGE ID      CONTAINER ID
alertmanager.ceph-mgr  ceph-mgr  *:9093,9094  running (98s)    97s ago  107s    15.2M        -  0.28.1   91c01b3cec9b  2bca804e1112
crash.ceph-mgr         ceph-mgr               running (45m)    97s ago    3w    19.2M        -  20.2.1   fb63cba66eea  ed24078efa6d
mgr.ceph-mgr.nwgopq    ceph-mgr  *:8443,8765  running (45m)    97s ago    3w     633M        -  20.2.1   fb63cba66eea  d8361cc56882
[root@ceph-mgr ~]#

次にメール設定を行います

[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/services/alertmanager/alertmanager.yml -i alertmanager.yml
 
[root@ceph-mgr ~]# ceph orch redeploy alertmanager
 
(確認)
[root@ceph-mgr ~]# curl -s http://localhost:9093/api/v2/status | jq -r .config.original     <-- smtp.gmail.comがあるか確認します

テストメールを投じてみます. ceph-mgrにて

[root@ceph-mgr ~]# curl -X POST http://localhost:9093/api/v2/alerts \
  -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%H:%M:%SZ")'"
    }
  ]'
[root@ceph-mgr ~]#

通信設定が上手く行ってれば、下記のようなGmailが届きます
2026y05m06d_020054902.png

Prometheus の構築

Alertmanagerと同様にコンテナで動きます

[root@ceph-mgr ~]# ceph orch apply prometheus --placement="ceph-mgr" --dry-run
 :
####################
SERVICESPEC PREVIEWS
####################
+------------+------------+----------+-------------+
|SERVICE     |NAME        |ADD_TO    |REMOVE_FROM  |
+------------+------------+----------+-------------+
|prometheus  |prometheus  |ceph-mgr  |             |
+------------+------------+----------+-------------+
 :
[root@ceph-mgr ~]# ceph orch apply prometheus --placement="ceph-mgr" 
 
[root@ceph-mgr ~]# ceph orch ps ceph-mgr
NAME                   HOST      PORTS        STATUS         REFRESHED  AGE  MEM USE  MEM LIM  VERSION  IMAGE ID      CONTAINER ID
alertmanager.ceph-mgr  ceph-mgr  *:9093,9094  running (15m)     3m ago  39m    19.8M        -  0.28.1   91c01b3cec9b  73758e00d14c
crash.ceph-mgr         ceph-mgr               running (83m)     3m ago   3w    19.2M        -  20.2.1   fb63cba66eea  ed24078efa6d
mgr.ceph-mgr.nwgopq    ceph-mgr  *:8443,8765  running (83m)     3m ago   3w     614M        -  20.2.1   fb63cba66eea  d8361cc56882
prometheus.ceph-mgr    ceph-mgr  *:9095       running (3m)      3m ago   3m    27.4M        -  3.6.0    4fcecf061b74  4e9a9ce8ec2d
 
[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 に通知を依頼するかはPrometheus内で用意されているルールファイルに従う
その内容は http://ceph-mgr:9095 の上部メニュー「Status」->「Rule health」にある
2026y05m06d_103515724.png
あるいは prometheus のコンテナ内の/etc/prometheus/alerting/ceph_alerts.ymlに書かれている
ここでは cintainer idが「4e9a9ce8ec2d」なので

[root@ceph-mgr ~]# podman exec -it 4e9a9ce8ec2d cat /etc/prometheus/alerting/ceph_alerts.yml

で閲覧できる.

ハード障害を起こしてみる

こちらは仮想マシンなのでいくらやっても大丈夫ですが、本番システムには適用しないように。。

osd hddの1つを停止してみる

[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  REWEIGHT  PRI-AFF
 -1         0.29279  root default
 -3         0.09760      host ceph-osd01
  1    hdd  0.04880          osd.1          down   1.00000  1.00000
  0    ssd  0.04880          osd.0            up   1.00000  1.00000
 -7         0.09760      host ceph-osd02
  3    hdd  0.04880          osd.3            up   1.00000  1.00000
  2    ssd  0.04880          osd.2            up   1.00000  1.00000
-10         0.09760      host ceph-osd03
  5    hdd  0.04880          osd.5            up   1.00000  1.00000
  4    ssd  0.04880          osd.4            up   1.00000  1.00000
[root@ceph-mgr ~]#
[root@ceph-mgr ~]# ceph health
HEALTH_WARN 1 osds down; Degraded data redundancy: 8/90 objects degraded (8.889%), 7 pgs degraded
 
[root@ceph-mgr ~]#

っでメールが届く
2026y05m06d_200205433.png 2026y05m06d_200210662.png

っで復旧させてみる

[root@ceph-mgr ~]# ceph orch daemon start osd.1
Scheduled to start osd.1 on host 'ceph-osd01'
[root@ceph-mgr ~]#

っでメールが届く
2026y05m06d_202802936.png 2026y05m06d_202756816.png

slackでも受け取りたい場合

[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/AAAAAAAAAAAAA/VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
        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/services/alertmanager/alertmanager.yml -i alertmanager.yml
[root@ceph-mgr ~]# ceph orch redeploy alertmanager
 
(確認)
[root@ceph-mgr ~]# ceph config-key get mgr/cephadm/services/alertmanager/alertmanager.yml

これでslackにも通知が届きます

slackでの「api_url」の値ですが、
slackの「チャンネル」欄の「+」から「チェンネルを作成する」を行います。
2026y05m11d_143138428.png
ここでは「#ceph-alert」を作ります

2026y05m08d_040034196.png
すると「チャンネル」欄に「#ceph-alrt」が表示されます

2026y05m11d_143500400.png

次に、「https://api.slack.com/apps」にアクセスして(認証がある場合はそれに応じて)
下記画面が表示されたら「Create an App」をクリックします
2026y05m08d_041720877.png

下記画面が表示されて、「From scratch」を押下します
2026y05m08d_041733813.png

appの名称を入れます。あとworkspaceを選択します。
ここではappの名称は「ceph-alerts」にしてます。「Create App」ボタンを押下します
2026y05m08d_041914428.png

作られた「ceph-alerts」アプリの設定画面が表示され、左縦メニューから「Incoming Webhooks」を選択します。
表示された「Incoming Webhooks」画面で、「Active Incoming Webhooks」を有効にして(OffからOnへ)、表示された項目「Webhook URLs for Your Workspace」の「Add New Webhook」ボタンを押下します
2026y05m08d_042051420.png

作ったAppをチャンネルにアサインします
2026y05m08d_042123908.png

すると Webhook 向けのURLが用意されます。「Webhook URL」欄にある「Copy」を押下すしてURLをコピーして 先ほどの api_url に貼り付けます。
2026y05m08d_042140435.png

「Sample curl request to post to channel:」にある文字列は、そのまま「Copy」してターミナルに貼って実行すればslackにメッセージが届きます。テスト用ですね。

最新の60件
2026-06-08 2026-06-06 2026-06-05 2026-06-04 2026-06-03 2026-05-31 2026-05-28 2026-05-26 2026-05-23 2026-05-22 2026-05-21 2026-05-20 2026-05-19 2026-05-18 2026-05-12 2026-05-11 2026-05-08 2026-05-06 2026-05-05 2026-05-03 2026-04-30 2026-04-29 2026-04-28 2026-04-27 2026-04-25 2026-04-24 2026-04-22 2026-04-21 2026-04-12 2026-04-08 2026-04-06 2026-04-05 2026-04-02 2026-03-26 2026-03-23 2026-03-21 2026-03-19 2026-03-15 2026-03-14

edit


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2026-05-11 (月) 15:06:14