
# MongoDB node by Zabbix agent 2

## Overview

The template to monitor single MongoDB server by Zabbix that work without any external scripts.
Most of the metrics are collected in one go, thanks to Zabbix bulk data collection.

`MongoDB node by Zabbix Agent 2` — collects metrics by polling zabbix-agent2.

## Requirements

Zabbix version: 7.0 and higher.

## Tested versions

This template has been tested on:
- MongoDB 4.0.21, 4.4.3

## Configuration

> Zabbix should be configured according to the instructions in the [Templates out of the box](https://www.zabbix.com/documentation/7.0/manual/config/templates_out_of_the_box) section.

## Setup

1. Setup and configure zabbix-agent2 compiled with the MongoDB monitoring plugin.
2. Set the {$MONGODB.CONNSTRING} such as <protocol(host:port)> or named session.
3. Set the user name and password in host macros ({$MONGODB.USER}, {$MONGODB.PASSWORD}) if you want to override parameters from the Zabbix agent configuration file.

**Note**, depending on the number of DBs and collections discovery operation may be expensive. Use filters with macros {$MONGODB.LLD.FILTER.DB.MATCHES}, {$MONGODB.LLD.FILTER.DB.NOT_MATCHES}, {$MONGODB.LLD.FILTER.COLLECTION.MATCHES}, {$MONGODB.LLD.FILTER.COLLECTION.NOT_MATCHES}.

Test availability: `zabbix_get -s mongodb.node -k 'mongodb.ping["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}"]"`

### Macros used

|Name|Description|Default|
|----|-----------|-------|
|{$MONGODB.CONNSTRING}|
Connection string in the URI format (password is not used). This param overwrites a value configured in the "Server" option of the configuration file (if it's set), otherwise, the plugin's default value is used: "tcp://localhost:27017"
|`tcp://localhost:27017`|
|{$MONGODB.USER}|
MongoDB username
||
|{$MONGODB.PASSWORD}|
MongoDB user password
||
|{$MONGODB.CONNS.PCT.USED.MAX.WARN}|
Maximum percentage of used connections
|`80`|
|{$MONGODB.CURSOR.TIMEOUT.MAX.WARN}|
Maximum number of cursors timing out per second
|`1`|
|{$MONGODB.CURSOR.OPEN.MAX.WARN}|
Maximum number of open cursors
|`10000`|
|{$MONGODB.REPL.LAG.MAX.WARN}|
Maximum replication lag in seconds
|`10s`|
|{$MONGODB.LLD.FILTER.COLLECTION.MATCHES}|
Filter of discoverable collections
|`.*`|
|{$MONGODB.LLD.FILTER.COLLECTION.NOT_MATCHES}|
Filter to exclude discovered collections
|`CHANGE_IF_NEEDED`|
|{$MONGODB.LLD.FILTER.DB.MATCHES}|
Filter of discoverable databases
|`.*`|
|{$MONGODB.LLD.FILTER.DB.NOT_MATCHES}|
Filter to exclude discovered databases
|`(admin\|config\|local)`|
|{$MONGODB.WIRED_TIGER.TICKETS.AVAILABLE.MIN.WARN}|
Minimum number of available WiredTiger read or write tickets remaining
|`5`|

### Items

|Name|Description|Type|Key and additional info|
|----|-----------|----|-----------------------|
|Get server status|
Returns a database's state.
|Zabbix agent|mongodb.server.status["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}"]|
|Get Replica Set status|
Returns the replica set status from the point of view of the member where the method is run.
|Zabbix agent|mongodb.rs.status["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}"]|
|Get oplog stats|
Returns status of the replica set, using data polled from the oplog.
|Zabbix agent|mongodb.oplog.stats["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}"]|
|Ping|
Test if a connection is alive or not.
|Zabbix agent|mongodb.ping["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}"]
**Preprocessing**

- 
Discard unchanged with heartbeat: `30m`

|
|Get collections usage stats|
Returns usage statistics for each collection.
|Zabbix agent|mongodb.collections.usage["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}"]|
|MongoDB version|
Version of the MongoDB server.
|Zabbix agent|mongodb.version["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}"]
**Preprocessing**

- 
Discard unchanged with heartbeat: `12h`

|
|Uptime|
Number of seconds that the mongod process has been active.
|Dependent item|mongodb.uptime
**Preprocessing**

- 
JSON Path: `$.uptime`

|
|Asserts: message, rate|
The number of message assertions raised per second.

Check the log file for more information about these messages.
|Dependent item|mongodb.asserts.msg.rate
**Preprocessing**

- 
JSON Path: `$.asserts.msg`

- Change per second
|
|Asserts: user, rate|
The number of "user asserts" that have occurred per second.

These are errors that user may generate, such as out of disk space or duplicate key.
|Dependent item|mongodb.asserts.user.rate
**Preprocessing**

- 
JSON Path: `$.asserts.user`

- Change per second
|
|Asserts: warning, rate|
The number of warnings raised per second.
|Dependent item|mongodb.asserts.warning.rate
**Preprocessing**

- 
JSON Path: `$.asserts.warning`

- Change per second
|
|Asserts: regular, rate|
The number of regular assertions raised per second.

Check the log file for more information about these messages.
|Dependent item|mongodb.asserts.regular.rate
**Preprocessing**

- 
JSON Path: `$.asserts.regular`

- Change per second
|
|Asserts: rollovers, rate|
Number of times that the rollover counters roll over per second.

The counters rollover to zero every 2^30 assertions.
|Dependent item|mongodb.asserts.rollovers.rate
**Preprocessing**

- 
JSON Path: `$.asserts.rollovers`

- Change per second
|
|Active clients: writers|
The number of active client connections performing write operations.
|Dependent item|mongodb.active_clients.writers
**Preprocessing**

- 
JSON Path: `$.globalLock.activeClients.writers`

|
|Active clients: readers|
The number of the active client connections performing read operations.
|Dependent item|mongodb.active_clients.readers
**Preprocessing**

- 
JSON Path: `$.globalLock.activeClients.readers`

|
|Active clients: total|
The total number of internal client connections to the database including system threads as well as queued readers and writers.
|Dependent item|mongodb.active_clients.total
**Preprocessing**

- 
JSON Path: `$.globalLock.activeClients.total`

|
|Current queue: writers|
The number of operations that are currently queued and waiting for the write lock.

 A consistently small write-queue, particularly of shorter operations, is no cause for concern.
|Dependent item|mongodb.current_queue.writers
**Preprocessing**

- 
JSON Path: `$.globalLock.currentQueue.writers`

|
|Current queue: readers|
The number of operations that are currently queued and waiting for the read lock.

A consistently small read-queue, particularly of shorter operations, should cause no concern.
|Dependent item|mongodb.current_queue.readers
**Preprocessing**

- 
JSON Path: `$.globalLock.currentQueue.readers`

|
|Current queue: total|
The total number of operations queued waiting for the lock.
|Dependent item|mongodb.current_queue.total
**Preprocessing**

- 
JSON Path: `$.globalLock.currentQueue.total`

|
|Operations: command, rate|
The number of commands issued to the database the mongod instance per second.

Counts all commands except the write commands: insert, update, and delete.
|Dependent item|mongodb.opcounters.command.rate
**Preprocessing**

- 
JSON Path: `$.opcounters.command`

- Change per second
|
|Operations: delete, rate|
The number of delete operations the mongod instance per second.
|Dependent item|mongodb.opcounters.delete.rate
**Preprocessing**

- 
JSON Path: `$.opcounters.delete`

- Change per second
|
|Operations: update, rate|
The number of update operations the mongod instance per second.
|Dependent item|mongodb.opcounters.update.rate
**Preprocessing**

- 
JSON Path: `$.opcounters.update`

- Change per second
|
|Operations: query, rate|
The number of queries received the mongod instance per second.
|Dependent item|mongodb.opcounters.query.rate
**Preprocessing**

- 
JSON Path: `$.opcounters.query`

- Change per second
|
|Operations: insert, rate|
The number of insert operations received since the mongod instance per second.
|Dependent item|mongodb.opcounters.insert.rate
**Preprocessing**

- 
JSON Path: `$.opcounters.insert`

- Change per second
|
|Operations: getmore, rate|
The number of "getmore" operations since the mongod instance per second. This counter can be high even if the query count is low.

Secondary nodes send getMore operations as part of the replication process.
|Dependent item|mongodb.opcounters.getmore.rate
**Preprocessing**

- 
JSON Path: `$.opcounters.getmore`

- Change per second
|
|Connections, current|
The number of incoming connections from clients to the database server.

This number includes the current shell session.
|Dependent item|mongodb.connections.current
**Preprocessing**

- 
JSON Path: `$.connections.current`

|
|New connections, rate|
Rate of all incoming connections created to the server.
|Dependent item|mongodb.connections.rate
**Preprocessing**

- 
JSON Path: `$.connections.totalCreated`

- Change per second
|
|Connections, available|
The number of unused incoming connections available.
|Dependent item|mongodb.connections.available
**Preprocessing**

- 
JSON Path: `$.connections.available`

|
|Connections, active|
The number of active client connections to the server.

Active client connections refers to client connections that currently have operations in progress.

Available starting in  4.0.7, 0 for older versions.
|Dependent item|mongodb.connections.active
**Preprocessing**

- 
JSON Path: `$.connections.active`

⛔️Custom on fail: Discard value

|
|Bytes in, rate|
The total number of bytes that the server has received over network connections initiated by clients or other mongod/mongos instances per second.
|Dependent item|mongodb.network.bytes_in.rate
**Preprocessing**

- 
JSON Path: `$.network.bytesIn`

- Change per second
|
|Bytes out, rate|
The total number of bytes that the server has sent over network connections initiated by clients or other mongod/mongos instances per second.
|Dependent item|mongodb.network.bytes_out.rate
**Preprocessing**

- 
JSON Path: `$.network.bytesOut`

- Change per second
|
|Requests, rate|
Number of distinct requests that the server has received per second
|Dependent item|mongodb.network.numRequests.rate
**Preprocessing**

- 
JSON Path: `$.network.numRequests`

- Change per second
|
|Document: deleted, rate|
Number of documents deleted per second.
|Dependent item|mongod.document.deleted.rate
**Preprocessing**

- 
JSON Path: `$.metrics.document.deleted`

- Change per second
|
|Document: inserted, rate|
Number of documents inserted per second.
|Dependent item|mongod.document.inserted.rate
**Preprocessing**

- 
JSON Path: `$.metrics.document.inserted`

- Change per second
|
|Document: returned, rate|
Number of documents returned by queries per second.
|Dependent item|mongod.document.returned.rate
**Preprocessing**

- 
JSON Path: `$.metrics.document.returned`

- Change per second
|
|Document: updated, rate|
Number of documents updated per second.
|Dependent item|mongod.document.updated.rate
**Preprocessing**

- 
JSON Path: `$.metrics.document.updated`

- Change per second
|
|Cursor: open no timeout|
Number of open cursors with the option DBQuery.Option.noTimeout set to prevent timeout after a period of inactivity.
|Dependent item|mongodb.metrics.cursor.open.no_timeout
**Preprocessing**

- 
JSON Path: `$.metrics.cursor.open.noTimeout`

|
|Cursor: open pinned|
Number of pinned open cursors.
|Dependent item|mongodb.cursor.open.pinned
**Preprocessing**

- 
JSON Path: `$.metrics.cursor.open.pinned`

|
|Cursor: open total|
Number of cursors that MongoDB is maintaining for clients.
|Dependent item|mongodb.cursor.open.total
**Preprocessing**

- 
JSON Path: `$.metrics.cursor.open.total`

|
|Cursor: timed out, rate|
Number of cursors that time out, per second.
|Dependent item|mongodb.cursor.timed_out.rate
**Preprocessing**

- 
JSON Path: `$.metrics.cursor.timedOut`

- Change per second
|
|Architecture|
A number, either 64 or 32, that indicates whether the MongoDB instance is compiled for 64-bit or 32-bit architecture.
|Dependent item|mongodb.mem.bits
**Preprocessing**

- 
JSON Path: `$.mem.bits`

- 
Discard unchanged with heartbeat: `3h`

|
|Memory: mapped|
Amount of mapped memory by the database.
|Dependent item|mongodb.mem.mapped
**Preprocessing**

- 
JSON Path: `$.mem.mapped`

⛔️Custom on fail: Discard value

- 
Custom multiplier: `1048576`

|
|Memory: mapped with journal|
The amount of mapped memory, including the memory used for journaling.
|Dependent item|mongodb.mem.mapped_with_journal
**Preprocessing**

- 
JSON Path: `$.mem.mappedWithJournal`

⛔️Custom on fail: Discard value

- 
Custom multiplier: `1048576`

|
|Memory: resident|
Amount of memory currently used by the database process.
|Dependent item|mongodb.mem.resident
**Preprocessing**

- 
JSON Path: `$.mem.resident`

- 
Custom multiplier: `1048576`

|
|Memory: virtual|
Amount of virtual memory used by the mongod process.
|Dependent item|mongodb.mem.virtual
**Preprocessing**

- 
JSON Path: `$.mem.virtual`

- 
Custom multiplier: `1048576`

|

### Triggers

|Name|Description|Expression|Severity|Dependencies and additional info|
|----|-----------|----------|--------|--------------------------------|
|MongoDB node: Connection to MongoDB is unavailable|
Connection to MongoDB instance is currently unavailable.
|`last(/MongoDB node by Zabbix agent 2/mongodb.ping["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}"])=0`|High||
|MongoDB node: Version has changed|
MongoDB version has changed. Acknowledge to close the problem manually.
|`last(/MongoDB node by Zabbix agent 2/mongodb.version["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}"],#1)<>last(/MongoDB node by Zabbix agent 2/mongodb.version["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}"],#2) and length(last(/MongoDB node by Zabbix agent 2/mongodb.version["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}"]))>0`|Info|**Manual close**: Yes|
|MongoDB node: mongod process has been restarted|
Uptime is less than 10 minutes.
|`last(/MongoDB node by Zabbix agent 2/mongodb.uptime)<10m`|Info|**Manual close**: Yes|
|MongoDB node: Failed to fetch info data|
Zabbix has not received data for items for the last 10 minutes
|`nodata(/MongoDB node by Zabbix agent 2/mongodb.uptime,10m)=1`|Warning|**Manual close**: Yes
**Depends on**:

- MongoDB node: Connection to MongoDB is unavailable
|
|MongoDB node: Total number of open connections is too high|
Too few available connections.
If MongoDB runs low on connections, in may not be able to handle incoming requests in a timely manner.
|`min(/MongoDB node by Zabbix agent 2/mongodb.connections.current,5m)/(last(/MongoDB node by Zabbix agent 2/mongodb.connections.available)+last(/MongoDB node by Zabbix agent 2/mongodb.connections.current))*100>{$MONGODB.CONNS.PCT.USED.MAX.WARN}`|Warning||
|MongoDB node: Too many cursors opened by MongoDB for clients||`min(/MongoDB node by Zabbix agent 2/mongodb.cursor.open.total,5m)>{$MONGODB.CURSOR.OPEN.MAX.WARN}`|Warning||
|MongoDB node: Too many cursors are timing out||`min(/MongoDB node by Zabbix agent 2/mongodb.cursor.timed_out.rate,5m)>{$MONGODB.CURSOR.TIMEOUT.MAX.WARN}`|Warning||

### LLD rule Database discovery

|Name|Description|Type|Key and additional info|
|----|-----------|----|-----------------------|
|Database discovery|
Collect database metrics.

Note, depending on the number of DBs this discovery operation may be expensive. Use filters with macros {$MONGODB.LLD.FILTER.DB.MATCHES}, {$MONGODB.LLD.FILTER.DB.NOT_MATCHES}.
|Zabbix agent|mongodb.db.discovery["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}"]|

### Item prototypes for Database discovery

|Name|Description|Type|Key and additional info|
|----|-----------|----|-----------------------|
|MongoDB {#DBNAME}: Get db stats {#DBNAME}|
Returns statistics reflecting the database system's state.
|Zabbix agent|mongodb.db.stats["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}","{#DBNAME}"]|
|MongoDB {#DBNAME}: Objects, avg size|
The average size of each document in bytes.
|Dependent item|mongodb.db.size["{#DBNAME}"]
**Preprocessing**

- 
JSON Path: `$.avgObjSize`

|
|MongoDB {#DBNAME}: Size, data|
Total size of the data held in this database including the padding factor.
|Dependent item|mongodb.db.data_size["{#DBNAME}"]
**Preprocessing**

- 
JSON Path: `$.dataSize`

|
|MongoDB {#DBNAME}: Size, file|
Total size of the data held in this database including the padding factor (only available with the mmapv1 storage engine).
|Dependent item|mongodb.db.file_size["{#DBNAME}"]
**Preprocessing**

- 
JSON Path: `$.fileSize`

⛔️Custom on fail: Discard value

|
|MongoDB {#DBNAME}: Size, index|
Total size of all indexes created on this database.
|Dependent item|mongodb.db.index_size["{#DBNAME}"]
**Preprocessing**

- 
JSON Path: `$.indexSize`

|
|MongoDB {#DBNAME}: Size, storage|
Total amount of space allocated to collections in this database for document storage.
|Dependent item|mongodb.db.storage_size["{#DBNAME}"]
**Preprocessing**

- 
JSON Path: `$.storageSize`

|
|MongoDB {#DBNAME}: Collections|
Contains a count of the number of collections in that database.
|Dependent item|mongodb.db.collections["{#DBNAME}"]
**Preprocessing**

- 
JSON Path: `$.collections`

|
|MongoDB {#DBNAME}: Objects, count|
Number of objects (documents) in the database across all collections.
|Dependent item|mongodb.db.objects["{#DBNAME}"]
**Preprocessing**

- 
JSON Path: `$.objects`

|
|MongoDB {#DBNAME}: Extents|
Contains a count of the number of extents in the database across all collections.
|Dependent item|mongodb.db.extents["{#DBNAME}"]
**Preprocessing**

- 
JSON Path: `$.numExtents`

⛔️Custom on fail: Discard value

|

### LLD rule Collection discovery

|Name|Description|Type|Key and additional info|
|----|-----------|----|-----------------------|
|Collection discovery|
Collect collections metrics.

Note, depending on the number of DBs and collections this discovery operation may be expensive. Use filters with macros {$MONGODB.LLD.FILTER.DB.MATCHES}, {$MONGODB.LLD.FILTER.DB.NOT_MATCHES}, {$MONGODB.LLD.FILTER.COLLECTION.MATCHES}, {$MONGODB.LLD.FILTER.COLLECTION.NOT_MATCHES}.
|Zabbix agent|mongodb.collections.discovery["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}"]|

### Item prototypes for Collection discovery

|Name|Description|Type|Key and additional info|
|----|-----------|----|-----------------------|
|MongoDB {#DBNAME}.{#COLLECTION}: Get collection stats {#DBNAME}.{#COLLECTION}|
Returns a variety of storage statistics for a given collection.
|Zabbix agent|mongodb.collection.stats["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}","{#DBNAME}","{#COLLECTION}"]|
|MongoDB {#DBNAME}.{#COLLECTION}: Size|
The total size in bytes of the data in the collection plus the size of every indexes on the mongodb.collection.
|Dependent item|mongodb.collection.size["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.size`

|
|MongoDB {#DBNAME}.{#COLLECTION}: Objects, avg size|
The size of the average object in the collection in bytes.
|Dependent item|mongodb.collection.avg_obj_size["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.avgObjSize`

⛔️Custom on fail: Discard value

|
|MongoDB {#DBNAME}.{#COLLECTION}: Objects, count|
Total number of objects in the collection.
|Dependent item|mongodb.collection.count["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.count`

|
|MongoDB {#DBNAME}.{#COLLECTION}: Capped: max number|
Maximum number of documents that may be present in a capped collection.
|Dependent item|mongodb.collection.max_number["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.max`

⛔️Custom on fail: Discard value

|
|MongoDB {#DBNAME}.{#COLLECTION}: Capped: max size|
Maximum size of a capped collection in bytes.
|Dependent item|mongodb.collection.max_size["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.maxSize`

⛔️Custom on fail: Discard value

|
|MongoDB {#DBNAME}.{#COLLECTION}: Storage size|
Total storage space allocated to this collection for document storage.
|Dependent item|mongodb.collection.storage_size["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.storageSize`

|
|MongoDB {#DBNAME}.{#COLLECTION}: Indexes|
Total number of indices on the collection.
|Dependent item|mongodb.collection.nindexes["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.nindexes`

|
|MongoDB {#DBNAME}.{#COLLECTION}: Capped|
Whether or not the collection is capped.
|Dependent item|mongodb.collection.capped["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.capped`

- Boolean to decimal
- 
Discard unchanged with heartbeat: `3h`

|
|MongoDB {#DBNAME}.{#COLLECTION}: Operations: total, rate|
The number of operations per second.
|Dependent item|mongodb.collection.ops.total.rate["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].total.count`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Read lock, rate|
The number of operations per second.
|Dependent item|mongodb.collection.read_lock.rate["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].readLock.count`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Write lock, rate|
The number of operations per second.
|Dependent item|mongodb.collection.write_lock.rate["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].writeLock.count`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Operations: queries, rate|
The number of operations per second.
|Dependent item|mongodb.collection.ops.queries.rate["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].queries.count`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Operations: getmore, rate|
The number of operations per second.
|Dependent item|mongodb.collection.ops.getmore.rate["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].getmore.count`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Operations: insert, rate|
The number of operations per second.
|Dependent item|mongodb.collection.ops.insert.rate["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].insert.count`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Operations: update, rate|
The number of operations per second.
|Dependent item|mongodb.collection.ops.update.rate["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].update.count`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Operations: remove, rate|
The number of operations per second.
|Dependent item|mongodb.collection.ops.remove.rate["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].remove.count`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Operations: commands, rate|
The number of operations per second.
|Dependent item|mongodb.collection.ops.commands.rate["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].commands.count`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Operations: total, ms/s|
Fraction of time (ms/s) the mongod has spent to operations.
|Dependent item|mongodb.collection.ops.total.ms["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].total.time`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Read lock, ms/s|
Fraction of time (ms/s) the mongod has spent to operations.
|Dependent item|mongodb.collection.read_lock.ms["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].readLock.time`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Write lock, ms/s|
Fraction of time (ms/s) the mongod has spent to operations.
|Dependent item|mongodb.collection.write_lock.ms["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].writeLock.time`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Operations: queries, ms/s|
Fraction of time (ms/s) the mongod has spent to operations.
|Dependent item|mongodb.collection.ops.queries.ms["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].queries.time`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Operations: getmore, ms/s|
Fraction of time (ms/s) the mongod has spent to operations.
|Dependent item|mongodb.collection.ops.getmore.ms["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].getmore.time`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Operations: insert, ms/s|
Fraction of time (ms/s) the mongod has spent to operations.
|Dependent item|mongodb.collection.ops.insert.ms["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].insert.time`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Operations: update, ms/s|
Fraction of time (ms/s) the mongod has spent to operations.
|Dependent item|mongodb.collection.ops.update.ms["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].update.time`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Operations: remove, ms/s|
Fraction of time (ms/s) the mongod has spent to operations.
|Dependent item|mongodb.collection.ops.remove.ms["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].remove.time`

- Change per second
|
|MongoDB {#DBNAME}.{#COLLECTION}: Operations: commands, ms/s|
Fraction of time (ms/s) the mongod has spent to operations.
|Dependent item|mongodb.collection.ops.commands.ms["{#DBNAME}","{#COLLECTION}"]
**Preprocessing**

- 
JSON Path: `$.totals["{#DBNAME}.{#COLLECTION}"].commands.time`

- Change per second
|

### LLD rule Replication discovery

|Name|Description|Type|Key and additional info|
|----|-----------|----|-----------------------|
|Replication discovery|
Collect metrics by Zabbix agent if it exists.
|Dependent item|mongodb.rs.discovery
**Preprocessing**

- 
JavaScript: `The text is too long. Please see the template.`

- 
Discard unchanged with heartbeat: `1h`

|

### Item prototypes for Replication discovery

|Name|Description|Type|Key and additional info|
|----|-----------|----|-----------------------|
|Node state|
An integer between 0 and 10 that represents the replica state of the current member.
|Dependent item|mongodb.rs.state[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.myState`

- 
Discard unchanged with heartbeat: `1h`

|
|Replication lag|
Delay between a write operation on the primary and its copy to a secondary.
|Dependent item|mongodb.rs.lag[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.members[?(@.self == "true")].lag.first()`

|
|Number of replicas|
The number of replicated nodes in current ReplicaSet.
|Dependent item|mongodb.rs.total_nodes[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.members[?(@.self == "true")].totalNodes.first()`

- 
Discard unchanged with heartbeat: `1h`

|
|Number of unhealthy replicas|
The number of replicated nodes with member health value  = 0.
|Dependent item|mongodb.rs.unhealthy_count[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.members[?(@.self == "true")].unhealthyCount.first()`

- 
Discard unchanged with heartbeat: `1h`

|
|Unhealthy replicas|
The replicated nodes in current ReplicaSet with member health value  = 0.
|Dependent item|mongodb.rs.unhealthy[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.members[?(@.self == "true")].unhealthyNodes.first()`

- 
JavaScript: `The text is too long. Please see the template.`

- 
Discard unchanged with heartbeat: `1h`

|
|Apply batches, rate|
Number of batches applied across all databases per second.
|Dependent item|mongodb.rs.apply.batches.rate[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.metrics.repl.apply.batches.num`

- Change per second
|
|Apply batches, ms/s|
Fraction of time (ms/s) the mongod has spent applying operations from the oplog.
|Dependent item|mongodb.rs.apply.batches.ms.rate[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.metrics.repl.apply.batches.totalMillis`

- Change per second
|
|Apply ops, rate|
Number of oplog operations applied per second.
|Dependent item|mongodb.rs.apply.rate[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.metrics.repl.apply.ops`

- Change per second
|
|Buffer|
Number of operations in the oplog buffer.
|Dependent item|mongodb.rs.buffer.count[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.metrics.repl.buffer.count`

|
|Buffer, max size|
Maximum size of the buffer.
|Dependent item|mongodb.rs.buffer.max_size[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.metrics.repl.buffer.maxSizeBytes`

|
|Buffer, size|
Current size of the contents of the oplog buffer.
|Dependent item|mongodb.rs.buffer.size[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.metrics.repl.buffer.sizeBytes`

|
|Network bytes, rate|
Amount of data read from the replication sync source per second.
|Dependent item|mongodb.rs.network.bytes.rate[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.metrics.repl.network.bytes`

- Change per second
|
|Network getmores, rate|
Number of getmore operations per second.
|Dependent item|mongodb.rs.network.getmores.rate[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.metrics.repl.network.getmores.num`

- Change per second
|
|Network getmores, ms/s|
Fraction of time (ms/s) required to collect data from getmore operations.
|Dependent item|mongodb.rs.network.getmores.ms.rate[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.metrics.repl.network.getmores.totalMillis`

- Change per second
|
|Network ops, rate|
Number of operations read from the replication source per second.
|Dependent item|mongodb.rs.network.ops.rate[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.metrics.repl.network.ops`

- Change per second
|
|Network readers created, rate|
Number of oplog query processes created per second.
|Dependent item|mongodb.rs.network.readers.rate[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.metrics.repl.network.readersCreated`

- Change per second
|
|MongoDB {#RS_NAME}: Oplog time diff|
Oplog window: difference between the first and last operation in the oplog. Only present if there are entries in the oplog.
|Dependent item|mongodb.rs.oplog.timediff[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.timediff`

|
|Preload docs, rate|
Number of documents loaded per second during the pre-fetch stage of replication.
|Dependent item|mongodb.rs.preload.docs.rate[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.metrics.repl.preload.docs.num`

⛔️Custom on fail: Discard value

- Change per second
|
|Preload docs, ms/s|
Fraction of time (ms/s) spent loading documents as part of the pre-fetch stage of replication.
|Dependent item|mongodb.rs.preload.docs.ms.rate[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.metrics.repl.preload.docs.totalMillis`

⛔️Custom on fail: Discard value

- Change per second
|
|Preload indexes, rate|
Number of index entries loaded by members before updating documents as part of the pre-fetch stage of replication.
|Dependent item|mongodb.rs.preload.indexes.rate[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.metrics.repl.preload.indexes.num`

⛔️Custom on fail: Discard value

- Change per second
|
|Preload indexes, ms/s|
Fraction of time (ms/s) spent loading documents as part of the pre-fetch stage of replication.
|Dependent item|mongodb.rs.preload.indexes.ms.rate[{#RS_NAME}]
**Preprocessing**

- 
JSON Path: `$.metrics.repl.preload.indexes.totalMillis`

⛔️Custom on fail: Discard value

- Change per second
|

### Trigger prototypes for Replication discovery

|Name|Description|Expression|Severity|Dependencies and additional info|
|----|-----------|----------|--------|--------------------------------|
|MongoDB node: Node in ReplicaSet changed the state|
Node in ReplicaSet  changed the state. Acknowledge to close the problem manually.
|`last(/MongoDB node by Zabbix agent 2/mongodb.rs.state[{#RS_NAME}],#1)<>last(/MongoDB node by Zabbix agent 2/mongodb.rs.state[{#RS_NAME}],#2)`|Warning|**Manual close**: Yes|
|MongoDB node: Replication lag with primary is too high||`min(/MongoDB node by Zabbix agent 2/mongodb.rs.lag[{#RS_NAME}],5m)>{$MONGODB.REPL.LAG.MAX.WARN}`|Warning||
|MongoDB node: There are unhealthy replicas in ReplicaSet||`last(/MongoDB node by Zabbix agent 2/mongodb.rs.unhealthy_count[{#RS_NAME}])>0 and length(last(/MongoDB node by Zabbix agent 2/mongodb.rs.unhealthy[{#RS_NAME}]))>0`|Average||

### LLD rule WiredTiger metrics

|Name|Description|Type|Key and additional info|
|----|-----------|----|-----------------------|
|WiredTiger metrics|
Collect metrics of WiredTiger Storage Engine if it exists.
|Dependent item|mongodb.wired_tiger.discovery
**Preprocessing**

- 
JavaScript: `The text is too long. Please see the template.`

- 
Discard unchanged with heartbeat: `6h`

|

### Item prototypes for WiredTiger metrics

|Name|Description|Type|Key and additional info|
|----|-----------|----|-----------------------|
|WiredTiger cache: bytes|
Size of the data currently in cache.
|Dependent item|mongodb.wired_tiger.cache.bytes_in_cache[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.cache['bytes currently in the cache']`

|
|WiredTiger cache: in-memory page splits|
In-memory page splits.
|Dependent item|mongodb.wired_tiger.cache.splits[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.cache['in-memory page splits']`

|
|WiredTiger cache: bytes, max|
Maximum cache size.
|Dependent item|mongodb.wired_tiger.cache.maximum_bytes_configured[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.cache['maximum bytes configured']`

|
|WiredTiger cache: max page size at eviction|
Maximum page size at eviction.
|Dependent item|mongodb.wired_tiger.cache.max_page_size_eviction[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.cache['maximum page size at eviction']`

|
|WiredTiger cache: modified pages evicted|
Number of pages, that have been modified, evicted from the cache.
|Dependent item|mongodb.wired_tiger.cache.modified_pages_evicted[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.cache['modified pages evicted']`

|
|WiredTiger cache: pages read into cache|
Number of pages read into the cache.
|Dependent item|mongodb.wired_tiger.cache.pages_read[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.cache['pages read into cache']`

|
|WiredTiger cache: pages written from cache|
Number of pages written from the cache.
|Dependent item|mongodb.wired_tiger.cache.pages_written[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.cache['pages written from cache']`

|
|WiredTiger cache: pages held in cache|
Number of pages currently held in the cache.
|Dependent item|mongodb.wired_tiger.cache.pages_in_cache[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.cache['pages currently held in the cache']`

|
|WiredTiger cache: pages evicted by application threads, rate|
Number of page evicted by application threads per second.
|Dependent item|mongodb.wired_tiger.cache.pages_evicted_threads.rate[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.cache.['pages evicted by application threads']`

|
|WiredTiger cache: tracked dirty bytes in the cache|
Size of the dirty data in the cache.
|Dependent item|mongodb.wired_tiger.cache.tracked_dirty_bytes[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.cache.['tracked dirty bytes in the cache']`

|
|WiredTiger cache: unmodified pages evicted|
Number of pages, that were not modified, evicted from the cache.
|Dependent item|mongodb.wired_tiger.cache.unmodified_pages_evicted[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.cache.['unmodified pages evicted']`

|
|WiredTiger concurrent transactions: read, available|
Number of available read tickets (concurrent transactions) remaining.
|Dependent item|mongodb.wired_tiger.concurrent_transactions.read.available[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.concurrentTransactions.read.available`

|
|WiredTiger concurrent transactions: read, out|
Number of read tickets (concurrent transactions) in use.
|Dependent item|mongodb.wired_tiger.concurrent_transactions.read.out[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.concurrentTransactions.read.out`

|
|WiredTiger concurrent transactions: read, total tickets|
Total number of read tickets (concurrent transactions) available.
|Dependent item|mongodb.wired_tiger.concurrent_transactions.read.totalTickets[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.concurrentTransactions.read.totalTickets`

|
|WiredTiger concurrent transactions: write, available|
Number of available write tickets (concurrent transactions) remaining.
|Dependent item|mongodb.wired_tiger.concurrent_transactions.write.available[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.concurrentTransactions.write.available`

|
|WiredTiger concurrent transactions: write, out|
Number of write tickets (concurrent transactions) in use.
|Dependent item|mongodb.wired_tiger.concurrent_transactions.write.out[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.concurrentTransactions.write.out`

|
|WiredTiger concurrent transactions: write, total tickets|
Total number of write tickets (concurrent transactions) available.
|Dependent item|mongodb.wired_tiger.concurrent_transactions.write.totalTickets[{#SINGLETON}]
**Preprocessing**

- 
JSON Path: `$.wiredTiger.concurrentTransactions.write.totalTickets`

|

### Trigger prototypes for WiredTiger metrics

|Name|Description|Expression|Severity|Dependencies and additional info|
|----|-----------|----------|--------|--------------------------------|
|MongoDB node: Available WiredTiger read tickets is low|
Too few available read tickets.
When the number of available read tickets remaining reaches zero, new read requests will be queued until a new read ticket is available.
|`max(/MongoDB node by Zabbix agent 2/mongodb.wired_tiger.concurrent_transactions.read.available[{#SINGLETON}],5m)<{$MONGODB.WIRED_TIGER.TICKETS.AVAILABLE.MIN.WARN}`|Warning||
|MongoDB node: Available WiredTiger write tickets is low|
Too few available write tickets.
When the number of available write tickets remaining reaches zero, new write requests will be queued until a new write ticket is available.
|`max(/MongoDB node by Zabbix agent 2/mongodb.wired_tiger.concurrent_transactions.write.available[{#SINGLETON}],5m)<{$MONGODB.WIRED_TIGER.TICKETS.AVAILABLE.MIN.WARN}`|Warning||

## Feedback

Please report any issues with the template at [`https://support.zabbix.com`](https://support.zabbix.com)

You can also provide feedback, discuss the template, or ask for help at [`ZABBIX forums`](https://www.zabbix.com/forum/zabbix-suggestions-and-feedback)

