Skip to main content
APA
Sponsored byCAST AI — Kubernetes cost optimizationBetter Stack — Uptime monitoring and log managementVictoriaMetrics — Fast, open-source time series database and drop-in Prometheus replacement.

MongoDB logoMongoDB Prometheus Alert Rules

22 Prometheus alerting rules for MongoDB.Exported via percona/mongodb_exporter, dcu/mongodb_exporter, stefanprodan/mgob.These rules cover critical and warning conditions — copy and paste the YAML into your Prometheus configuration.

⚠️

Alert thresholds depend on the nature of your applications. Some queries may have arbitrary tolerance thresholds. Building an efficient monitoring platform takes time. 😉

2.9.1.MongoDB logopercona/mongodb_exporter(12 rules)

wget https://raw.githubusercontent.com/samber/awesome-prometheus-alerts/refs/heads/master/dist/rules/mongodb/percona-mongodb-exporter.yml
critical

2.9.1.1.MongoDB Down

MongoDB instance is down

  # 1m delay allows a restart without triggering an alert.
- alert: MongoDBDown
  expr: mongodb_up == 0
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: MongoDB Down (instance {{ $labels.instance }})
    description: "MongoDB instance is down\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

2.9.1.2.Mongodb replica member unhealthy

MongoDB replica member is not healthy

  # 1m delay allows a restart without triggering an alert.
- alert: MongodbReplicaMemberUnhealthy
  expr: mongodb_rs_members_health == 0
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: Mongodb replica member unhealthy (instance {{ $labels.instance }})
    description: "MongoDB replica member is not healthy\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

2.9.1.3.MongoDB replica set has no primary

MongoDB replica set {{ $labels.job }} has no writable primary, so all writes will fail until a new primary is elected.

- alert: MongoDBReplicaSetHasNoPrimary
  expr: sum(mongodb_ss_repl_isWritablePrimary) by (job) == 0
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: MongoDB replica set has no primary (instance {{ $labels.instance }})
    description: "MongoDB replica set {{ $labels.job }} has no writable primary, so all writes will fail until a new primary is elected.\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

2.9.1.4.MongoDB replica set primary changed

MongoDB member {{ $labels.instance }} became the replica set primary in the last 10 minutes, which may indicate an election due to failover or instability.

  # mongodb_rs_myState (this node's replica set state) is exposed in default mode.
  # Restricted to == 1 (PRIMARY) so the alert fires once per election, from the new primary's series, instead of on every member state transition (e.g. a secondary's restart/resync cycle).
  # Older exporters (or --compatible-mode) instead expose mongodb_mongod_replset_my_state.
- alert: MongoDBReplicaSetPrimaryChanged
  expr: changes(mongodb_rs_myState[10m]) > 0 and mongodb_rs_myState == 1
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: MongoDB replica set primary changed (instance {{ $labels.instance }})
    description: "MongoDB member {{ $labels.instance }} became the replica set primary in the last 10 minutes, which may indicate an election due to failover or instability.\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

2.9.1.5.MongoDB too many connections (Percona)

Too many connections (> 80%)

- alert: MongoDBTooManyConnections(Percona)
  expr: mongodb_ss_connections{conn_type="current"} / (mongodb_ss_connections{conn_type="current"} + mongodb_ss_connections{conn_type="available"}) * 100 > 80 and (mongodb_ss_connections{conn_type="current"} + mongodb_ss_connections{conn_type="available"}) > 0
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: MongoDB too many connections (Percona) (instance {{ $labels.instance }})
    description: "Too many connections (> 80%)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

2.9.1.6.MongoDB replication headroom

MongoDB replication headroom is <= 0

  # This query mixes old (mongodb_mongod_*) and new (mongodb_rs_*) metric names. It requires the Percona exporter to run with --compatible-mode to expose both.
- alert: MongoDBReplicationHeadroom
  expr: sum(avg(mongodb_mongod_replset_oplog_head_timestamp - mongodb_mongod_replset_oplog_tail_timestamp)) - sum(avg(mongodb_rs_members_optimeDate{member_state="PRIMARY"} - on (set) group_right mongodb_rs_members_optimeDate{member_state="SECONDARY"})) <= 0
  for: 0m
  labels:
    severity: critical
  annotations:
    summary: MongoDB replication headroom (instance {{ $labels.instance }})
    description: "MongoDB replication headroom is <= 0\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

2.9.1.7.MongoDB replication lag (Percona)

Mongodb replication lag is more than 30s

  # mongodb_rs_members_optimeDate is exposed in default mode; its value is in milliseconds, hence the /1000 to compare seconds.
  # Older exporters (or --compatible-mode) instead expose a ready-made lag in seconds: mongodb_mongod_replset_member_replication_lag > 30.
- alert: MongoDBReplicationLag(Percona)
  expr: (mongodb_rs_members_optimeDate{member_state="PRIMARY"} - on (set) group_right mongodb_rs_members_optimeDate{member_state="SECONDARY"}) / 1000 > 30
  for: 0m
  labels:
    severity: warning
  annotations:
    summary: MongoDB replication lag (Percona) (instance {{ $labels.instance }})
    description: "Mongodb replication lag is more than 30s\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

2.9.1.8.MongoDB number cursors open (Percona)

Too many cursors opened by MongoDB for clients (> 10k)

  # 10k cursors is a rough default; cursor count scales with your concurrent client and query load — adjust based on your workload.
- alert: MongoDBNumberCursorsOpen(Percona)
  expr: mongodb_ss_metrics_cursor_open{csr_type="total"} > 10 * 1000
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: MongoDB number cursors open (Percona) (instance {{ $labels.instance }})
    description: "Too many cursors opened by MongoDB for clients (> 10k)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

2.9.1.9.MongoDB cursors timeouts (Percona)

Too many cursors are timing out ({{ $value }} in the last minute)

  # 100 timeouts/min is a rough default; scales with your query volume and concurrency — adjust based on your workload.
- alert: MongoDBCursorsTimeouts(Percona)
  expr: increase(mongodb_ss_metrics_cursor_timedOut[1m]) > 100
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: MongoDB cursors timeouts (Percona) (instance {{ $labels.instance }})
    description: "Too many cursors are timing out ({{ $value }} in the last minute)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

2.9.1.10.MongoDB WiredTiger read tickets exhausted

WiredTiger available read tickets on {{ $labels.instance }} have dropped to {{ $value }}, which causes read requests to queue and latency to spike.

  # 50 is a rough default relative to MongoDB's default 128 concurrent read transactions; adjust based on your configured wiredTigerConcurrentReadTransactions and workload concurrency.
- alert: MongoDBWiredTigerReadTicketsExhausted
  expr: mongodb_ss_wt_concurrentTransactions_available{txn_rw_type="read"} < 50
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: MongoDB WiredTiger read tickets exhausted (instance {{ $labels.instance }})
    description: "WiredTiger available read tickets on {{ $labels.instance }} have dropped to {{ $value }}, which causes read requests to queue and latency to spike.\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

2.9.1.11.MongoDB WiredTiger write tickets exhausted

WiredTiger available write tickets on {{ $labels.instance }} have dropped to {{ $value }}, which causes write requests to queue and latency to spike.

  # 50 is a rough default relative to MongoDB's default 128 concurrent write transactions; adjust based on your configured wiredTigerConcurrentWriteTransactions and workload concurrency.
- alert: MongoDBWiredTigerWriteTicketsExhausted
  expr: mongodb_ss_wt_concurrentTransactions_available{txn_rw_type="write"} < 50
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: MongoDB WiredTiger write tickets exhausted (instance {{ $labels.instance }})
    description: "WiredTiger available write tickets on {{ $labels.instance }} have dropped to {{ $value }}, which causes write requests to queue and latency to spike.\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
info

2.9.1.12.MongoDB instance recently restarted

MongoDB instance {{ $labels.instance }} was restarted {{ $value }} seconds ago.

  # mongodb_ss_uptime (from serverStatus.uptime) is exposed in default mode.
  # Older exporters (or --compatible-mode) instead expose mongodb_instance_uptime_seconds.
- alert: MongoDBInstanceRecentlyRestarted
  expr: mongodb_ss_uptime < 300
  for: 0m
  labels:
    severity: info
  annotations:
    summary: MongoDB instance recently restarted (instance {{ $labels.instance }})
    description: "MongoDB instance {{ $labels.instance }} was restarted {{ $value }} seconds ago.\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"

2.9.2.MongoDB logodcu/mongodb_exporter(9 rules)

wget https://raw.githubusercontent.com/samber/awesome-prometheus-alerts/refs/heads/master/dist/rules/mongodb/dcu-mongodb-exporter.yml
critical

2.9.2.1.MongoDB replication Status 8

MongoDB Replication set member as seen from another member of the set, is unreachable

- alert: MongoDBReplicationStatus8
  expr: mongodb_replset_member_state == 8
  for: 0m
  labels:
    severity: critical
  annotations:
    summary: MongoDB replication Status 8 (instance {{ $labels.instance }})
    description: "MongoDB Replication set member as seen from another member of the set, is unreachable\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

2.9.2.2.MongoDB too many connections (DCU)

Too many connections (> 80%)

- alert: MongoDBTooManyConnections(DCU)
  expr: mongodb_connections{state="current"} / (mongodb_connections{state="current"} + mongodb_connections{state="available"}) * 100 > 80 and (mongodb_connections{state="current"} + mongodb_connections{state="available"}) > 0
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: MongoDB too many connections (DCU) (instance {{ $labels.instance }})
    description: "Too many connections (> 80%)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

2.9.2.3.MongoDB replication lag (DCU)

Mongodb replication lag is more than 10s

  # 10s threshold is a rough default; acceptable lag depends on your network and replication workload — adjust based on your baseline.
- alert: MongoDBReplicationLag(DCU)
  expr: avg(mongodb_replset_member_optime_date{state="PRIMARY"}) - avg(mongodb_replset_member_optime_date{state="SECONDARY"}) > 10
  for: 0m
  labels:
    severity: critical
  annotations:
    summary: MongoDB replication lag (DCU) (instance {{ $labels.instance }})
    description: "Mongodb replication lag is more than 10s\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

2.9.2.4.MongoDB replication Status 3

MongoDB Replication set member either perform startup self-checks, or transition from completing a rollback or resync

- alert: MongoDBReplicationStatus3
  expr: mongodb_replset_member_state == 3
  for: 0m
  labels:
    severity: critical
  annotations:
    summary: MongoDB replication Status 3 (instance {{ $labels.instance }})
    description: "MongoDB Replication set member either perform startup self-checks, or transition from completing a rollback or resync\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

2.9.2.5.MongoDB replication Status 6

MongoDB Replication set member as seen from another member of the set, is not yet known

- alert: MongoDBReplicationStatus6
  expr: mongodb_replset_member_state == 6
  for: 0m
  labels:
    severity: critical
  annotations:
    summary: MongoDB replication Status 6 (instance {{ $labels.instance }})
    description: "MongoDB Replication set member as seen from another member of the set, is not yet known\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

2.9.2.6.MongoDB replication Status 9

MongoDB Replication set member is actively performing a rollback. Data is not available for reads

- alert: MongoDBReplicationStatus9
  expr: mongodb_replset_member_state == 9
  for: 0m
  labels:
    severity: critical
  annotations:
    summary: MongoDB replication Status 9 (instance {{ $labels.instance }})
    description: "MongoDB Replication set member is actively performing a rollback. Data is not available for reads\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

2.9.2.7.MongoDB replication Status 10

MongoDB Replication set member was once in a replica set but was subsequently removed

- alert: MongoDBReplicationStatus10
  expr: mongodb_replset_member_state == 10
  for: 0m
  labels:
    severity: critical
  annotations:
    summary: MongoDB replication Status 10 (instance {{ $labels.instance }})
    description: "MongoDB Replication set member was once in a replica set but was subsequently removed\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

2.9.2.8.MongoDB number cursors open (DCU)

Too many cursors opened by MongoDB for clients (> 10k)

  # 10k cursors is a rough default; cursor count scales with your concurrent client and query load — adjust based on your workload.
- alert: MongoDBNumberCursorsOpen(DCU)
  expr: mongodb_metrics_cursor_open{state="total_open"} > 10000
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: MongoDB number cursors open (DCU) (instance {{ $labels.instance }})
    description: "Too many cursors opened by MongoDB for clients (> 10k)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

2.9.2.9.MongoDB cursors timeouts (DCU)

Too many cursors are timing out ({{ $value }} in the last minute)

  # 100 timeouts/min is a rough default; scales with your query volume and concurrency — adjust based on your workload.
- alert: MongoDBCursorsTimeouts(DCU)
  expr: increase(mongodb_metrics_cursor_timed_out_total[1m]) > 100
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: MongoDB cursors timeouts (DCU) (instance {{ $labels.instance }})
    description: "Too many cursors are timing out ({{ $value }} in the last minute)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"

2.9.3.MongoDB logostefanprodan/mgob(1 rules)

wget https://raw.githubusercontent.com/samber/awesome-prometheus-alerts/refs/heads/master/dist/rules/mongodb/stefanprodan-mgob-exporter.yml
critical

2.9.3.1.Mgob backup failed

MongoDB backup has failed

- alert: MgobBackupFailed
  expr: changes(mgob_scheduler_backup_total{status="500"}[1h]) > 0
  for: 0m
  labels:
    severity: critical
  annotations:
    summary: Mgob backup failed (instance {{ $labels.instance }})
    description: "MongoDB backup has failed\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"