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

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

Alertmanager: 通知の判断と配送役

PrometheusとAlertmanagerは共にcephからデプロイされるのですが、Alertmanagerが外部へのメール転送ができないようで
cephに寄らず自らデプロイしたのだが、その場合、Prometheusとの連携も出来なかった。なのでこの2つとも手動でデプロイすることにした.

構築 Prometheus

ceph-mgr(192.168.0.47)にて構築します

[root@ceph-mgr ~]# ceph mgr module enable prometheus      # ceph由来のprometheusコンテナは作らないが、独自に作ったprometheusコンテナからデータを引っ張ってくるのでこれで開けておく
 
[root@ceph-mgr ~]# mkdir -p /opt/monitoring/prometheus
[root@ceph-mgr ~]# mkdir -p /opt/monitoring/alertmanager

設定ファイルを用意します
Prometheus設定
「scrape_configs:」でcephからのデータを集めます
「rule_files:」でデータの閾値が定義されて、それを超えたのが
「alerting:」にてalertmanagerからメールが出される

[root@ceph-mgr ~]# cat /opt/monitoring/prometheus/prometheus.yml
global:
  scrape_interval: 15s
 
scrape_configs:
  - job_name: ceph
    static_configs:
      - targets:
        - 192.168.0.47:9283   #  cephのデータを取得します. ここではceph-mgrから
        - 192.168.0.48:9283   #  もう一つのmanagerも指定
rule_files:
  - /etc/prometheus/alert.rules.yml
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          - 192.168.0.47:9093   # ← Alertmanager
[root@ceph-mgr ~]#

Alertを発するルールを決めます

[root@ceph-mgr ~]# cat /opt/monitoring/prometheus/alert.rules.yml
groups:
- name: ceph-health
  rules:
 
  # クラスタ異常
  - alert: CephHealthError
    expr: ceph_health_status == 2
    for: 1m
    labels:
      severity: critical
    annotations:
      summary: "Ceph Health ERROR"
      description: "Ceph cluster is in ERROR state"
 
  # 警告
  - alert: CephHealthWarning
    expr: ceph_health_status == 1
    for: 5m
    labels:
      severity: warning
    annotations:
      summary: "Ceph Health WARNING"
 
  # OSDダウン
  - alert: CephOSDDown
    expr: ceph_osd_up == 0
    for: 2m
    labels:
      severity: critical
    annotations:
      summary: "OSD Down"
      description: "OSD {{ $labels.ceph_daemon } } is down"    <-- コピペの際は} と}の間のスペースを削除
 
  # 容量逼迫(80%)
  - alert: CephNearFull
    expr: ceph_cluster_total_used_bytes / ceph_cluster_total_bytes > 0.8
    for: 10m
    labels:
      severity: warning
    annotations:
      summary: "Ceph usage > 80%"
 
  # 容量危険(90%)
  - alert: CephFull
    expr: ceph_cluster_total_used_bytes / ceph_cluster_total_bytes > 0.9
    for: 5m
    labels:
      severity: critical
    annotations:
      summary: "Ceph usage > 90%"
[root@ceph-mgr ~]#

そしてメール通知を行う alertmanager の設定です

(Alertmanager設定)
[root@ceph-mgr ~]# cat /opt/monitoring/alertmanager/alertmanager.yml
global:
  smtp_smarthost: 'smtp.gmail.com:587'
  smtp_from: 'xxxxxxxxxxxxxxxxxxxxxxxxxx@gmail.com'
  smtp_auth_username: 'xxxxxxxxxxxxxxxxxxxxxxxxxx@gmail.com'
  smtp_auth_password: 'aaaa bbbb cccc dddd'
  smtp_require_tls: true
 
route:
  group_by: ['alertname']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 3h
  receiver: 'email-admin'
 
receivers:
- name: 'email-admin'
  email_configs:
  - to: 'xxxxxxxxxxxxxxxxxxxxxxxxxx@gmail.com'
    send_resolved: true
 
[root@ceph-mgr ~]#

設定ファイルが用意できたので、alertmanager と prometheus を起動させます

alertmanager と prometheus の起動

まずはalertmanagerコンテナを起動します. ceph由来ではなく、独自で起動させます

[root@ceph-mgr ~]# podman run -d \
  --name alertmanager \
  -p 9093:9093 \
  -v /opt/monitoring/alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml:Z \
  quay.io/prometheus/alertmanager
 
[root@ceph-mgr ~]# podman run -d \
  --name prometheus \
  -p 9090:9090 \
  -v /opt/monitoring/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:Z \
  -v /opt/monitoring/prometheus/alert.rules.yml:/etc/prometheus/alert.rules.yml:Z \
  quay.io/prometheus/prometheus
 
[root@ceph-mgr ~]#

「alertmanager.yml」を修正したら

[root@ceph-mgr ~]# podman restart alertmanager
 
[root@ceph-mgr ~]# podman logs alertmanager     <--ログ確認

「prometheus.yml」もしくは「alert.rules.yml」を修正したら

[root@ceph-mgr ~]# podman restart prometheus 
 
[root@ceph-mgr ~]# podman logs prometheus     <--ログ確認

と行う

テストメールを流してみる

実際に問題がでないと通知が来ないので正しく設定されているのか不明。
なので、メール通信テストをまずは行ってみる
まずはalertmanagerにダイレクトにデータを流してメール通知をさせてみる

[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に通知が来ればok
2026y04m29d_035714946.png

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

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

[root@ceph-mgr ~]# ceph orch daemon stop osd.1
 
[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 ~]#

即応じゃなくて暫くしてからメールが届きますね. 2通. OSDの話とHealthのお話で
2026y04m29d_050908832.png 2026y04m29d_050915273.png

っで復旧させてみる

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

2026y04m29d_051037471.png 2026y04m29d_051044191.png

最新の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-05 (火) 12:12:09