diff options
Diffstat (limited to '')
-rw-r--r-- | collectors/python.d.plugin/mongodb/Makefile.inc | 13 | ||||
-rw-r--r-- | collectors/python.d.plugin/mongodb/README.md | 141 | ||||
-rw-r--r-- | collectors/python.d.plugin/mongodb/mongodb.chart.py (renamed from python.d/mongodb.chart.py) | 150 | ||||
-rw-r--r-- | collectors/python.d.plugin/mongodb/mongodb.conf (renamed from conf.d/python.d/mongodb.conf) | 0 |
4 files changed, 258 insertions, 46 deletions
diff --git a/collectors/python.d.plugin/mongodb/Makefile.inc b/collectors/python.d.plugin/mongodb/Makefile.inc new file mode 100644 index 000000000..784945aa6 --- /dev/null +++ b/collectors/python.d.plugin/mongodb/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_python_DATA += mongodb/mongodb.chart.py +dist_pythonconfig_DATA += mongodb/mongodb.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += mongodb/README.md mongodb/Makefile.inc + diff --git a/collectors/python.d.plugin/mongodb/README.md b/collectors/python.d.plugin/mongodb/README.md new file mode 100644 index 000000000..8e5f652c5 --- /dev/null +++ b/collectors/python.d.plugin/mongodb/README.md @@ -0,0 +1,141 @@ +# mongodb + +Module monitor mongodb performance and health metrics + +**Requirements:** + * `python-pymongo` package v2.4+. + +You need to install it manually. + + +Number of charts depends on mongodb version, storage engine and other features (replication): + +1. **Read requests**: + * query + * getmore (operation the cursor executes to get additional data from query) + +2. **Write requests**: + * insert + * delete + * update + +3. **Active clients**: + * readers (number of clients with read operations in progress or queued) + * writers (number of clients with write operations in progress or queued) + +4. **Journal transactions**: + * commits (count of transactions that have been written to the journal) + +5. **Data written to the journal**: + * volume (volume of data) + +6. **Background flush** (MMAPv1): + * average ms (average time taken by flushes to execute) + * last ms (time taken by the last flush) + +8. **Read tickets** (WiredTiger): + * in use (number of read tickets in use) + * available (number of available read tickets remaining) + +9. **Write tickets** (WiredTiger): + * in use (number of write tickets in use) + * available (number of available write tickets remaining) + +10. **Cursors**: + * opened (number of cursors currently opened by MongoDB for clients) + * timedOut (number of cursors that have timed) + * noTimeout (number of open cursors with timeout disabled) + +11. **Connections**: + * connected (number of clients currently connected to the database server) + * unused (number of unused connections available for new clients) + +12. **Memory usage metrics**: + * virtual + * resident (amount of memory used by the database process) + * mapped + * non mapped + +13. **Page faults**: + * page faults (number of times MongoDB had to request from disk) + +14. **Cache metrics** (WiredTiger): + * percentage of bytes currently in the cache (amount of space taken by cached data) + * percantage of tracked dirty bytes in the cache (amount of space taken by dirty data) + +15. **Pages evicted from cache** (WiredTiger): + * modified + * unmodified + +16. **Queued requests**: + * readers (number of read request currently queued) + * writers (number of write request currently queued) + +17. **Errors**: + * msg (number of message assertions raised) + * warning (number of warning assertions raised) + * regular (number of regular assertions raised) + * user (number of assertions corresponding to errors generated by users) + +18. **Storage metrics** (one chart for every database) + * dataSize (size of all documents + padding in the database) + * indexSize (size of all indexes in the database) + * storageSize (size of all extents in the database) + +19. **Documents in the database** (one chart for all databases) + * documents (number of objects in the database among all the collections) + +20. **tcmalloc metrics** + * central cache free + * current total thread cache + * pageheap free + * pageheap unmapped + * thread cache free + * transfer cache free + * heap size + +21. **Commands total/failed rate** + * count + * createIndex + * delete + * eval + * findAndModify + * insert + +22. **Locks metrics** (acquireCount metrics - number of times the lock was acquired in the specified mode) + * Global lock + * Database lock + * Collection lock + * Metadata lock + * oplog lock + +23. **Replica set members state** + * state + +24. **Oplog window** + * window (interval of time between the oldest and the latest entries in the oplog) + +25. **Replication lag** + * member (time when last entry from the oplog was applied for every member) + +26. **Replication set member heartbeat latency** + * member (time when last heartbeat was received from replica set member) + + +### configuration + +Sample: + +```yaml +local: + name : 'local' + host : '127.0.0.1' + port : 27017 + user : 'netdata' + pass : 'netdata' + +``` + +If no configuration is given, module will attempt to connect to mongodb daemon on `127.0.0.1:27017` address + +--- diff --git a/python.d/mongodb.chart.py b/collectors/python.d.plugin/mongodb/mongodb.chart.py index 909a419da..10344342d 100644 --- a/python.d/mongodb.chart.py +++ b/collectors/python.d.plugin/mongodb/mongodb.chart.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Description: mongodb netdata python.d module # Author: l2isbad +# SPDX-License-Identifier: GPL-3.0-or-later from copy import deepcopy from datetime import datetime @@ -31,7 +32,8 @@ REPL_SET_STATES = [ ('6', 'unknown'), ('9', 'rollback'), ('10', 'removed'), - ('0', 'startup')] + ('0', 'startup') +] def multiply_by_100(value): @@ -141,12 +143,37 @@ DBSTATS = [ ] # charts order (can be overridden if you want less charts, or different order) -ORDER = ['read_operations', 'write_operations', 'active_clients', 'journaling_transactions', - 'journaling_volume', 'background_flush_average', 'background_flush_last', 'background_flush_rate', - 'wiredtiger_read', 'wiredtiger_write', 'cursors', 'connections', 'memory', 'page_faults', - 'queued_requests', 'record_moves', 'wiredtiger_cache', 'wiredtiger_pages_evicted', 'asserts', - 'locks_collection', 'locks_database', 'locks_global', 'locks_metadata', 'locks_oplog', - 'dbstats_objects', 'tcmalloc_generic', 'tcmalloc_metrics', 'command_total_rate', 'command_failed_rate'] +ORDER = [ + 'read_operations', + 'write_operations', + 'active_clients', + 'journaling_transactions', + 'journaling_volume', + 'background_flush_average', + 'background_flush_last', + 'background_flush_rate', + 'wiredtiger_read', + 'wiredtiger_write', + 'cursors', + 'connections', + 'memory', + 'page_faults', + 'queued_requests', + 'record_moves', + 'wiredtiger_cache', + 'wiredtiger_pages_evicted', + 'asserts', + 'locks_collection', + 'locks_database', + 'locks_global', + 'locks_metadata', + 'locks_oplog', + 'dbstats_objects', + 'tcmalloc_generic', + 'tcmalloc_metrics', + 'command_total_rate', + 'command_failed_rate' +] CHARTS = { 'read_operations': { @@ -155,7 +182,8 @@ CHARTS = { 'lines': [ ['query', None, 'incremental'], ['getmore', None, 'incremental'] - ]}, + ] + }, 'write_operations': { 'options': [None, 'Received write requests', 'requests/s', 'throughput metrics', 'mongodb.write_operations', 'line'], @@ -163,57 +191,66 @@ CHARTS = { ['insert', None, 'incremental'], ['update', None, 'incremental'], ['delete', None, 'incremental'] - ]}, + ] + }, 'active_clients': { 'options': [None, 'Clients with read or write operations in progress or queued', 'clients', 'throughput metrics', 'mongodb.active_clients', 'line'], 'lines': [ ['activeClients_readers', 'readers', 'absolute'], ['activeClients_writers', 'writers', 'absolute'] - ]}, + ] + }, 'journaling_transactions': { 'options': [None, 'Transactions that have been written to the journal', 'commits', 'database performance', 'mongodb.journaling_transactions', 'line'], 'lines': [ ['commits', None, 'absolute'] - ]}, + ] + }, 'journaling_volume': { 'options': [None, 'Volume of data written to the journal', 'MB', 'database performance', 'mongodb.journaling_volume', 'line'], 'lines': [ ['journaledMB', 'volume', 'absolute', 1, 100] - ]}, + ] + }, 'background_flush_average': { 'options': [None, 'Average time taken by flushes to execute', 'ms', 'database performance', 'mongodb.background_flush_average', 'line'], 'lines': [ ['average_ms', 'time', 'absolute', 1, 100] - ]}, + ] + }, 'background_flush_last': { 'options': [None, 'Time taken by the last flush operation to execute', 'ms', 'database performance', 'mongodb.background_flush_last', 'line'], 'lines': [ ['last_ms', 'time', 'absolute', 1, 100] - ]}, + ] + }, 'background_flush_rate': { 'options': [None, 'Flushes rate', 'flushes', 'database performance', 'mongodb.background_flush_rate', 'line'], 'lines': [ ['flushes', 'flushes', 'incremental', 1, 1] - ]}, + ] + }, 'wiredtiger_read': { 'options': [None, 'Read tickets in use and remaining', 'tickets', 'database performance', 'mongodb.wiredtiger_read', 'stacked'], 'lines': [ ['wiredTigerRead_available', 'available', 'absolute', 1, 1], ['wiredTigerRead_out', 'inuse', 'absolute', 1, 1] - ]}, + ] + }, 'wiredtiger_write': { 'options': [None, 'Write tickets in use and remaining', 'tickets', 'database performance', 'mongodb.wiredtiger_write', 'stacked'], 'lines': [ ['wiredTigerWrite_available', 'available', 'absolute', 1, 1], ['wiredTigerWrite_out', 'inuse', 'absolute', 1, 1] - ]}, + ] + }, 'cursors': { 'options': [None, 'Currently openned cursors, cursors with timeout disabled and timed out cursors', 'cursors', 'database performance', 'mongodb.cursors', 'stacked'], @@ -221,14 +258,16 @@ CHARTS = { ['cursor_total', 'openned', 'absolute', 1, 1], ['noTimeout', None, 'absolute', 1, 1], ['timedOut', None, 'incremental', 1, 1] - ]}, + ] + }, 'connections': { 'options': [None, 'Currently connected clients and unused connections', 'connections', 'resource utilization', 'mongodb.connections', 'stacked'], 'lines': [ ['connections_available', 'unused', 'absolute', 1, 1], ['connections_current', 'connected', 'absolute', 1, 1] - ]}, + ] + }, 'memory': { 'options': [None, 'Memory metrics', 'MB', 'resource utilization', 'mongodb.memory', 'stacked'], 'lines': [ @@ -236,60 +275,70 @@ CHARTS = { ['resident', None, 'absolute', 1, 1], ['nonmapped', None, 'absolute', 1, 1], ['mapped', None, 'absolute', 1, 1] - ]}, + ] + }, 'page_faults': { 'options': [None, 'Number of times MongoDB had to fetch data from disk', 'request/s', 'resource utilization', 'mongodb.page_faults', 'line'], 'lines': [ ['page_faults', None, 'incremental', 1, 1] - ]}, + ] + }, 'queued_requests': { - 'options': [None, 'Currently queued read and wrire requests', 'requests', 'resource saturation', + 'options': [None, 'Currently queued read and write requests', 'requests', 'resource saturation', 'mongodb.queued_requests', 'line'], 'lines': [ ['currentQueue_readers', 'readers', 'absolute', 1, 1], ['currentQueue_writers', 'writers', 'absolute', 1, 1] - ]}, + ] + }, 'record_moves': { 'options': [None, 'Number of times documents had to be moved on-disk', 'number', 'resource saturation', 'mongodb.record_moves', 'line'], 'lines': [ ['moves', None, 'incremental', 1, 1] - ]}, + ] + }, 'asserts': { - 'options': [None, 'Number of message, warning, regular, corresponding to errors generated' - ' by users assertions raised', 'number', 'errors (asserts)', 'mongodb.asserts', 'line'], + 'options': [ + None, + 'Number of message, warning, regular, corresponding to errors generated by users assertions raised', + 'number', 'errors (asserts)', 'mongodb.asserts', 'line'], 'lines': [ ['msg', None, 'incremental', 1, 1], ['warning', None, 'incremental', 1, 1], ['regular', None, 'incremental', 1, 1], ['user', None, 'incremental', 1, 1] - ]}, + ] + }, 'wiredtiger_cache': { 'options': [None, 'The percentage of the wiredTiger cache that is in use and cache with dirty bytes', 'percent', 'resource utilization', 'mongodb.wiredtiger_cache', 'stacked'], 'lines': [ ['wiredTiger_percent_clean', 'inuse', 'absolute', 1, 1000], ['wiredTiger_percent_dirty', 'dirty', 'absolute', 1, 1000] - ]}, + ] + }, 'wiredtiger_pages_evicted': { 'options': [None, 'Pages evicted from the cache', 'pages', 'resource utilization', 'mongodb.wiredtiger_pages_evicted', 'stacked'], 'lines': [ ['unmodified', None, 'absolute', 1, 1], ['modified', None, 'absolute', 1, 1] - ]}, + ] + }, 'dbstats_objects': { 'options': [None, 'Number of documents in the database among all the collections', 'documents', 'storage size metrics', 'mongodb.dbstats_objects', 'stacked'], - 'lines': [ - ]}, + 'lines': [] + }, 'tcmalloc_generic': { 'options': [None, 'Tcmalloc generic metrics', 'MB', 'tcmalloc', 'mongodb.tcmalloc_generic', 'stacked'], 'lines': [ ['current_allocated_bytes', 'allocated', 'absolute', 1, 1048576], ['heap_size', 'heap_size', 'absolute', 1, 1048576] - ]}, + ] + }, 'tcmalloc_metrics': { 'options': [None, 'Tcmalloc metrics', 'KB', 'tcmalloc', 'mongodb.tcmalloc_metrics', 'stacked'], 'lines': [ @@ -299,7 +348,8 @@ CHARTS = { ['pageheap_unmapped_bytes', 'pageheap_unmapped', 'absolute', 1, 1024], ['thread_cache_free_bytes', 'thread_cache_free', 'absolute', 1, 1024], ['transfer_cache_free_bytes', 'transfer_cache_free', 'absolute', 1, 1024] - ]}, + ] + }, 'command_total_rate': { 'options': [None, 'Commands total rate', 'commands/s', 'commands', 'mongodb.command_total_rate', 'stacked'], 'lines': [ @@ -310,7 +360,8 @@ CHARTS = { ['findAndModify_total', 'findAndModify', 'incremental', 1, 1], ['insert_total', 'insert', 'incremental', 1, 1], ['update_total', 'update', 'incremental', 1, 1] - ]}, + ] + }, 'command_failed_rate': { 'options': [None, 'Commands failed rate', 'commands/s', 'commands', 'mongodb.command_failed_rate', 'stacked'], 'lines': [ @@ -321,7 +372,8 @@ CHARTS = { ['findAndModify_failed', 'findAndModify', 'incremental', 1, 1], ['insert_failed', 'insert', 'incremental', 1, 1], ['update_failed', 'update', 'incremental', 1, 1] - ]}, + ] + }, 'locks_collection': { 'options': [None, 'Collection lock. Number of times the lock was acquired in the specified mode', 'locks', 'locks metrics', 'mongodb.locks_collection', 'stacked'], @@ -330,7 +382,8 @@ CHARTS = { ['Collection_W', 'exclusive', 'incremental'], ['Collection_r', 'intent_shared', 'incremental'], ['Collection_w', 'intent_exclusive', 'incremental'] - ]}, + ] + }, 'locks_database': { 'options': [None, 'Database lock. Number of times the lock was acquired in the specified mode', 'locks', 'locks metrics', 'mongodb.locks_database', 'stacked'], @@ -339,7 +392,8 @@ CHARTS = { ['Database_W', 'exclusive', 'incremental'], ['Database_r', 'intent_shared', 'incremental'], ['Database_w', 'intent_exclusive', 'incremental'] - ]}, + ] + }, 'locks_global': { 'options': [None, 'Global lock. Number of times the lock was acquired in the specified mode', 'locks', 'locks metrics', 'mongodb.locks_global', 'stacked'], @@ -348,21 +402,24 @@ CHARTS = { ['Global_W', 'exclusive', 'incremental'], ['Global_r', 'intent_shared', 'incremental'], ['Global_w', 'intent_exclusive', 'incremental'] - ]}, + ] + }, 'locks_metadata': { 'options': [None, 'Metadata lock. Number of times the lock was acquired in the specified mode', 'locks', 'locks metrics', 'mongodb.locks_metadata', 'stacked'], 'lines': [ ['Metadata_R', 'shared', 'incremental'], ['Metadata_w', 'intent_exclusive', 'incremental'] - ]}, + ] + }, 'locks_oplog': { 'options': [None, 'Lock on the oplog. Number of times the lock was acquired in the specified mode', 'locks', 'locks metrics', 'mongodb.locks_oplog', 'stacked'], 'lines': [ ['oplog_r', 'intent_shared', 'incremental'], ['oplog_w', 'intent_exclusive', 'incremental'] - ]} + ] + } } @@ -383,7 +440,7 @@ class Service(SimpleService): def check(self): if not PYMONGO: - self.error('Pymongo module is needed to use mongodb.chart.py') + self.error('Pymongo package v2.4+ is needed to use mongodb.chart.py') return False self.connection, server_status, error = self._create_connection() if error: @@ -491,9 +548,10 @@ class Service(SimpleService): # Create "heartbeat delay" chart self.order.append('heartbeat_delay') self.definitions['heartbeat_delay'] = { - 'options': [None, 'Time when last heartbeat was received' - ' from the replica set member (lastHeartbeatRecv)', - 'seconds ago', 'replication and oplog', 'mongodb.replication_heartbeat_delay', 'stacked'], + 'options': [ + None, + 'Time when last heartbeat was received from the replica set member (lastHeartbeatRecv)', + 'seconds ago', 'replication and oplog', 'mongodb.replication_heartbeat_delay', 'stacked'], 'lines': create_lines(other_hosts, 'heartbeat_lag')} # Create "optimedate delay" chart self.order.append('optimedate_delay') @@ -561,9 +619,9 @@ class Service(SimpleService): raw_data['getReplicationInfo'] = dict() try: raw_data['getReplicationInfo']['ASCENDING'] = self.connection.local.oplog.rs.find().sort( - "$natural", ASCENDING).limit(1)[0] + '$natural', ASCENDING).limit(1)[0] raw_data['getReplicationInfo']['DESCENDING'] = self.connection.local.oplog.rs.find().sort( - "$natural", DESCENDING).limit(1)[0] + '$natural', DESCENDING).limit(1)[0] return raw_data except PyMongoError: return None diff --git a/conf.d/python.d/mongodb.conf b/collectors/python.d.plugin/mongodb/mongodb.conf index 62faef68d..62faef68d 100644 --- a/conf.d/python.d/mongodb.conf +++ b/collectors/python.d.plugin/mongodb/mongodb.conf |