Ceph Cluster Monitoring with Prometheus: Tracking OSDs, IOPS, and Storage Capacity

Monitoring tutorial - IT technology blog
Monitoring tutorial - IT technology blog

Why Proactive Ceph Storage Monitoring Is Essential

Anyone who has operated Ceph in production knows the dread of disk failures striking in the middle of the night. A 12-node Ceph cluster supporting 300 Proxmox virtual machines or hundreds of Kubernetes PersistentVolumes can grind to a halt in seconds. As soon as a single OSD changes state to down/out, Ceph immediately triggers backfilling and recovery mechanisms. Internal network bandwidth gets completely saturated, severe I/O bottlenecks emerge, and service latencies spike across the board.

Historically, engineers often had to SSH into individual nodes every morning to run ceph status or ceph osd tree. This manual approach makes it dangerously easy to overlook looming risks. Aggregating metrics into Prometheus enables operations teams to immediately spot critical warning signs—such as pools approaching threshold limits (nearfull ratio at 85%), IOPS hitting saturation caps, or SSDs showing performance degradation—long before end users start complaining.

Starting with Nautilus and newer releases (Pacific, Quincy, Reef), Ceph includes a built-in Prometheus module directly inside Ceph Manager (ceph-mgr). This mechanism is lightweight, resource-efficient, and far more stable than maintaining standalone external exporter daemons.

Enabling the Ceph Exporter via ceph-mgr

Using the built-in module directly is the best-practice approach. You do not need to install any third-party packages or extra dependencies.

Step 1: Enable the Prometheus Module

Log in to the Ceph Admin node or any node running ceph-mgr, then run the following commands:

# Enable the prometheus module
ceph mgr module enable prometheus

# Verify the module operational status
ceph mgr module ls | grep prometheus

Step 2: Specify the Listening IP and Service Port

By default, the module binds to port 9283 across all network interfaces (0.0.0.0). To enhance security, restrict the exporter to listen only on your internal management network IP (Management VLAN):

# Bind internal IP and port 9283
ceph config set mgr mgr/prometheus/server_addr 10.10.20.11
ceph config set mgr mgr/prometheus/server_port 9283

# Restart the active ceph-mgr daemon to apply changes
ceph mgr fail $(ceph mgr dump | jq -r .active_name)

Step 3: Verify the Metrics Endpoint

Directly test the newly enabled endpoint using curl:

curl -s http://10.10.20.11:9283/metrics | head -n 25

If the output displays a series of metrics prefixed with ceph_, your exporter is functioning properly.

Configuring Prometheus Server and Setting Up Alerts

Once the endpoint is exposed successfully, configure Prometheus to scrape metrics periodically and define alert rules.

Step 1: Add the Scraping Job to prometheus.yml

In a Ceph cluster, only one ceph-mgr node is active at any given time, while the remaining nodes stay in standby mode. You should declare all mgr nodes in the configuration file. Prometheus will automatically track the active target without interruption during failover:

scrape_configs:
  - job_name: 'ceph-cluster'
    scrape_interval: 15s
    scrape_timeout: 10s
    metrics_path: /metrics
    static_configs:
      - targets:
          - '10.10.20.11:9283' # ceph-mgr-01
          - '10.10.20.12:9283' # ceph-mgr-02
          - '10.10.20.13:9283' # ceph-mgr-03
        labels:
          cluster: 'ceph-prod-dc01'

Reload the Prometheus configuration immediately without restarting the service:

curl -X POST http://localhost:9090/-/reload

Step 2: Create Alert Rules for Incident Prevention

A monitoring system is only effective when alerts are delivered in time. Add these essential rules to your ceph_alerts.yml file:

groups:
  - name: CephStorageAlerts
    rules:
      - alert: CephClusterHealthWarn
        expr: ceph_health_status == 1
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "Ceph cluster is in HEALTH_WARN state"
          description: "Cluster {{ $labels.cluster }} has been in WARN state for more than 5 minutes."

      - alert: CephClusterHealthError
        expr: ceph_health_status == 2
        for: 1m
        labels:
          severity: critical
        annotations:
          summary: "Ceph cluster critical error HEALTH_ERR"
          description: "Cluster {{ $labels.cluster }} has entered HEALTH_ERR. Urgent intervention required!"

      - alert: CephOSDDown
        expr: count(ceph_osd_up == 0) > 0
        for: 3m
        labels:
          severity: critical
        annotations:
          summary: "OSD down detected"
          description: "{{ $value }} OSD(s) in DOWN state on cluster {{ $labels.cluster }}."

      - alert: CephPoolNearFull
        expr: (ceph_pool_bytes_used / (ceph_pool_bytes_used + ceph_pool_max_avail)) * 100 > 80
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "Ceph pool is approaching full capacity"
          description: "Pool {{ $labels.pool_id }} has used more than 80% of its available capacity."

Core PromQL Metrics to Monitor on Dashboards

Below are the most critical PromQL queries to include in your daily Grafana dashboard.

1. Monitoring OSD Health

OSD status immediately reflects physical disk health and network connectivity between nodes:

  • List of disconnected OSDs (Down):
    ceph_osd_up == 0
    Returns the list of OSDs whose processes crashed or whose physical drives were abruptly disconnected.
  • Total count of failing OSDs:
    count(ceph_osd_up == 0) or vector(0)
  • OSDs removed from the cluster (Out of CRUSH Map):
    ceph_osd_in == 0

2. Measuring IOPS and Read/Write Throughput per Pool

Close I/O monitoring helps pinpoint noisy-neighbor virtual machines or applications causing bottlenecks:

  • Read IOPS:
    rate(ceph_pool_rd[1m])
  • Write IOPS:
    rate(ceph_pool_wr[1m])
  • Actual Read Throughput (MB/s):
    rate(ceph_pool_rd_bytes[1m]) / 1048576
  • Actual Write Throughput (MB/s):
    rate(ceph_pool_wr_bytes[1m]) / 1048576

3. Managing Capacity and Storage Variance Across OSDs

Ceph exhibits a noticeable performance drop when overall storage reaches the nearfull_ratio (typically 85%). If it hits the full_ratio (90%), Ceph halts all write operations to protect data integrity, causing severe service outages.

  • Cluster-wide storage utilization percentage:
    (ceph_cluster_total_used_bytes / ceph_cluster_total_bytes) * 100
  • Actual stored capacity per pool (GB):
    ceph_pool_stored_bytes / 1073741824
  • Capacity variance across OSDs (OSD Variance):
    ceph_osd_stat_bytes_used / ceph_osd_stat_bytes
    When this ratio deviates by more than 15–20% among drives of the same type, Placement Group (PG) distribution has become unbalanced. You should proactively run ceph osd reweight-by-utilization to rebalance the cluster load.

Once you have configured these metrics, simply import Grafana Dashboard ID 2842 or 533 to gain complete visibility into the health of your Ceph storage cluster.

Share: