StackState-MongoDB Integration

Overview

Connect MongoDB to StackState in order to:

  • Visualize key MongoDB metrics.
  • Correlate MongoDB performance with the rest of your applications.

Setup

Installation

  1. To capture MongoDB metrics you need to install the StackState Agent.
  2. Create a read-only user for StackState, with the appropriate MongoDB roles to collect complete server statistics. In the mongo shell, run:
    # Authenticate as the admin user.
    use admin
    db.auth("admin", "admin-password")
    
    # On MongoDB 2.x, use the addUser command.
    db.addUser("stackstate", "<UNIQUEPASSWORD>", true)
    
    # On MongoDB 3.x or higher, use the createUser command.
    db.createUser({
    "user":"stackstate",
      "pwd": "<UNIQUEPASSWORD>",
      "roles" : [
        {role: 'read', db: 'admin' },
        {role: 'clusterMonitor', db: 'admin'},
        {role: 'read', db: 'local' }
      ]
    })
    

Configuration

  1. Edit your conf.d/mongo.yaml file as follows:

    init_config:
    
    instances:
      # The format for the server entry below is:
      # server: mongodb://username:password@host:port/database where database will default to admin
      - server: mongodb://admin:stackstate@localhost:27017/admin
        tags:
          - mytag1
          - mytag2
        additional_metrics:
          - durability
          - locks
          - top
    

  2. Restart the agent

Validation

To validate that the integration is working, run /etc/init.d/stackstate-agent info. You should see results similar to the following:

Checks
======

  mongo
  -----
    - instance #0 [OK]
    - Collected 89 metrics, 0 events & 2 service checks
    - Dependencies:
        - pymongo: 2.8

Data Collected

Metrics

mongodb.asserts.msgps
(gauge)
Number of message assertions raised per second.
shown as assertion
mongodb.asserts.regularps
(gauge)
Number of regular assertions raised per second.
shown as assertion
mongodb.asserts.rolloversps
(gauge)
Number of times that the rollover counters roll over per second. The counters rollover to zero every 2^30 assertions.
shown as assertion
mongodb.asserts.userps
(gauge)
Number of user assertions raised per second.
shown as assertion
mongodb.asserts.warningps
(gauge)
Number of warnings raised per second.
shown as assertion
mongodb.backgroundflushing.average_ms
(gauge)
Average time for each flush to disk.
shown as millisecond
mongodb.backgroundflushing.flushesps
(gauge)
Number of times the database has flushed all writes to disk.
shown as flush
mongodb.backgroundflushing.last_ms
(gauge)
Amount of time that the last flush operation took to complete.
shown as millisecond
mongodb.backgroundflushing.total_ms
(gauge)
Total number of time that the `mongod` processes have spent writing (i.e. flushing) data to disk.
shown as millisecond
mongodb.connections.available
(gauge)
Number of unused available incoming connections the database can provide.
shown as connection
mongodb.connections.current
(gauge)
Number of connections to the database server from clients.
shown as connection
mongodb.cursors.timedout
(gauge)
Total number of cursors that have timed out since the server process started.
shown as cursor
mongodb.cursors.totalopen
(gauge)
Number of cursors that MongoDB is maintaining for clients
shown as cursor
mongodb.dur.commits
(gauge)
Number of transactions written to the journal during the last journal group commit interval.
shown as transaction
mongodb.dur.commitsinwritelock
(gauge)
Count of the commits that occurred while a write lock was held.
shown as commit
mongodb.dur.compression
(gauge)
Compression ratio of the data written to the journal.
shown as fraction
mongodb.dur.earlycommits
(gauge)
Number of times MongoDB requested a commit before the scheduled journal group commit interval.
shown as commit
mongodb.dur.journaledmb
(gauge)
Amount of data written to journal during the last journal group commit interval.
shown as mebibyte
mongodb.dur.timems.commits
(gauge)
Amount of time spent for commits.
shown as millisecond
mongodb.dur.timems.commitsinwritelock
(gauge)
Amount of time spent for commits that occurred while a write lock was held.
shown as millisecond
mongodb.dur.timems.dt
(gauge)
Amount of time over which MongoDB collected the `dur.timeMS` data.
shown as millisecond
mongodb.dur.timems.preplogbuffer
(gauge)
Amount of time spent preparing to write to the journal.
shown as millisecond
mongodb.dur.timems.remapprivateview
(gauge)
Amount of time spent remapping copy-on-write memory mapped views.
shown as millisecond
mongodb.dur.timems.writetodatafiles
(gauge)
Amount of time spent writing to data files after journaling.
shown as millisecond
mongodb.dur.timems.writetojournal
(gauge)
Amount of time spent writing to the journal
shown as millisecond
mongodb.dur.writetodatafilesmb
(gauge)
Amount of data written from journal to the data files during the last journal group commit interval.
shown as mebibyte
mongodb.extra_info.page_faultsps
(gauge)
Number of page faults per second that require disk operations.
shown as fault
mongodb.globallock.activeclients.readers
(gauge)
Count of the active client connections performing read operations.
shown as connection
mongodb.globallock.activeclients.total
(gauge)
Total number of active client connections to the database.
shown as connection
mongodb.globallock.activeclients.writers
(gauge)
Count of active client connections performing write operations.
shown as connection
mongodb.globallock.currentqueue.readers
(gauge)
Number of operations that are currently queued and waiting for the read lock.
shown as operation
mongodb.globallock.currentqueue.total
(gauge)
Total number of operations queued waiting for the lock.
shown as operation
mongodb.globallock.currentqueue.writers
(gauge)
Number of operations that are currently queued and waiting for the write lock.
shown as operation
mongodb.globallock.locktime
(gauge)
Time since the database last started that the globalLock has been held.
shown as millisecond
mongodb.globallock.ratio
(gauge)
Ratio of the time that the globalLock has been held to the total time since it was created.
shown as fraction
mongodb.globallock.totaltime
(gauge)
Time since the database last started and created the global lock.
shown as microsecond
mongodb.indexcounters.accessesps
(gauge)
Number of times that operations have accessed indexes per second.
shown as event
mongodb.indexcounters.hitsps
(gauge)
Number of times per second that an index has been accessed and mongod is able to return the index from memory.
shown as hit
mongodb.indexcounters.missesps
(gauge)
Number of times per second that an operation attempted to access an index that was not in memory.
shown as miss
mongodb.indexcounters.missratio
(gauge)
Ratio of index hits to misses.
shown as fraction
mongodb.indexcounters.resetsps
(gauge)
Number of times per second the index counters have been reset.
shown as event
mongodb.locks.collection.acquirecount.exclusiveps
(gauge)
Number of times the collection lock type was aquired in the Exclusive (X) mode.
shown as lock
mongodb.locks.collection.acquirecount.intent_exclusiveps
(gauge)
Number of times the collection lock type was aquired in the Intent Exclusive (IX) mode.
shown as lock
mongodb.locks.collection.acquirecount.intent_sharedps
(gauge)
Number of times the collection lock type was aquired in the Intent Shared (IS) mode.
shown as lock
mongodb.locks.collection.acquirecount.sharedps
(gauge)
Number of times the collection lock type was aquired in the Shared (S) mode.
shown as lock
mongodb.locks.collection.acquirewaitcount.exclusiveps
(gauge)
Number of times the collection lock type acquisition in the Exclusive (X) mode encountered waits because the locks were held in a conflicting mode.
shown as wait
mongodb.locks.collection.acquirewaitcount.sharedps
(gauge)
Number of times the collection lock type acquisition in the Shared (S) mode encountered waits because the locks were held in a conflicting mode.
shown as wait
mongodb.locks.collection.timeacquiringmicros.exclusiveps
(gauge)
Wait time for the collection lock type acquisitions in the Exclusive (X) mode.
shown as fraction
mongodb.locks.collection.timeacquiringmicros.sharedps
(gauge)
Wait time for the collection lock type acquisitions in the Shared (S) mode.
shown as fraction
mongodb.locks.database.acquirecount.exclusiveps
(gauge)
Number of times the database lock type was aquired in the Exclusive (X) mode.
shown as lock
mongodb.locks.database.acquirecount.intent_exclusiveps
(gauge)
Number of times the database lock type was aquired in the Intent Exclusive (IX) mode.
shown as lock
mongodb.locks.database.acquirecount.intent_sharedps
(gauge)
Number of times the database lock type was aquired in the Intent Shared (IS) mode.
shown as lock
mongodb.locks.database.acquirecount.sharedps
(gauge)
Number of times the database lock type was aquired in the Shared (S) mode.
shown as lock
mongodb.locks.database.acquirewaitcount.exclusiveps
(gauge)
Number of times the database lock type acquisition in the Exclusive (X) mode encountered waits because the locks were held in a conflicting mode.
shown as wait
mongodb.locks.database.acquirewaitcount.intent_exclusiveps
(gauge)
Number of times the database lock type acquisition in the Intent Exclusive (IX) mode encountered waits because the locks were held in a conflicting mode.
shown as wait
mongodb.locks.database.acquirewaitcount.intent_sharedps
(gauge)
Number of times the database lock type acquisition in the Intent Shared (IS) mode encountered waits because the locks were held in a conflicting mode.
shown as wait
mongodb.locks.database.acquirewaitcount.sharedps
(gauge)
Number of times the database lock type acquisition in the Shared (S) mode encountered waits because the locks were held in a conflicting mode.
shown as wait
mongodb.locks.database.timeacquiringmicros.exclusiveps
(gauge)
Wait time for the database lock type acquisitions in the Exclusive (X) mode.
shown as fraction
mongodb.locks.database.timeacquiringmicros.intent_exclusiveps
(gauge)
Wait time for the database lock type acquisitions in the Intent Exclusive (IX) mode.
shown as fraction
mongodb.locks.database.timeacquiringmicros.intent_sharedps
(gauge)
Wait time for the database lock type acquisitions in the Intent Shared (IS) mode.
shown as fraction
mongodb.locks.database.timeacquiringmicros.sharedps
(gauge)
Wait time for the database lock type acquisitions in the Shared (S) mode.
shown as fraction
mongodb.locks.global.acquirecount.exclusiveps
(gauge)
Number of times the global lock type was aquired in the Exclusive (X) mode.
shown as lock
mongodb.locks.global.acquirecount.intent_exclusiveps
(gauge)
Number of times the global lock type was aquired in the Intent Exclusive (IX) mode.
shown as lock
mongodb.locks.global.acquirecount.intent_sharedps
(gauge)
Number of times the global lock type was aquired in the Intent Shared (IS) mode.
shown as lock
mongodb.locks.global.acquirecount.sharedps
(gauge)
Number of times the global lock type was aquired in the Shared (S) mode.
shown as lock
mongodb.locks.global.acquirewaitcount.exclusiveps
(gauge)
Number of times the global lock type acquisition in the Exclusive (X) mode encountered waits because the locks were held in a conflicting mode.
shown as wait
mongodb.locks.global.acquirewaitcount.intent_exclusiveps
(gauge)
Number of times the global lock type acquisition in the Intent Exclusive (IX) mode encountered waits because the locks were held in a conflicting mode.
shown as wait
mongodb.locks.global.acquirewaitcount.intent_sharedps
(gauge)
Number of times the global lock type acquisition in the Intent Shared (IS) mode encountered waits because the locks were held in a conflicting mode.
shown as wait
mongodb.locks.global.acquirewaitcount.sharedps
(gauge)
Number of times the global lock type acquisition in the Shared (S) mode encountered waits because the locks were held in a conflicting mode.
shown as wait
mongodb.locks.global.timeacquiringmicros.exclusiveps
(gauge)
Wait time for the global lock type acquisitions in the Exclusive (X) mode.
shown as fraction
mongodb.locks.global.timeacquiringmicros.intent_exclusiveps
(gauge)
Wait time for the global lock type acquisitions in the Intent Exclusive (IX) mode.
shown as fraction
mongodb.locks.global.timeacquiringmicros.intent_sharedps
(gauge)
Wait time for the global lock type acquisitions in the Intent Shared (IS) mode.
shown as fraction
mongodb.locks.global.timeacquiringmicros.sharedps
(gauge)
Wait time for the global lock type acquisitions in the Shared (S) mode.
shown as fraction
mongodb.locks.metadata.acquirecount.exclusiveps
(gauge)
Number of times the metadata lock type was aquired in the Exclusive (X) mode.
shown as lock
mongodb.locks.metadata.acquirecount.sharedps
(gauge)
Number of times the metadata lock type was aquired in the Shared (S) mode.
shown as lock
mongodb.locks.mmapv1journal.acquirecount.intent_exclusiveps
(gauge)
Number of times the MMAPv1 storage engine lock type was aquired in the Intent Exclusive (IX) mode.
shown as lock
mongodb.locks.mmapv1journal.acquirecount.intent_sharedps
(gauge)
Number of times the MMAPv1 storage engine lock type was aquired in the Intent Shared (IS) mode.
shown as lock
mongodb.locks.mmapv1journal.acquirewaitcount.intent_exclusiveps
(gauge)
Number of times the MMAPv1 storage engine lock type acquisition in the Intent Exclusive (IX) mode encountered waits because the locks were held in a conflicting mode.
shown as wait
mongodb.locks.mmapv1journal.acquirewaitcount.intent_sharedps
(gauge)
Number of times the MMAPv1 storage engine lock type acquisition in the Intent Shared (IS) mode encountered waits because the locks were held in a conflicting mode.
shown as wait
mongodb.locks.mmapv1journal.timeacquiringmicros.intent_exclusiveps
(gauge)
Wait time for the MMAPv1 storage engine lock type acquisitions in the Intent Exclusive (IX) mode.
shown as fraction
mongodb.locks.mmapv1journal.timeacquiringmicros.intent_sharedps
(gauge)
Wait time for the MMAPv1 storage engine lock type acquisitions in the Intent Shared (IS) mode.
shown as fraction
mongodb.locks.oplog.acquirecount.intent_exclusiveps
(gauge)
Number of times the oplog lock type was aquired in the Intent Exclusive (IX) mode.
shown as lock
mongodb.locks.oplog.acquirecount.sharedps
(gauge)
Number of times the oplog lock type was aquired in the Shared (S) mode.
shown as lock
mongodb.locks.oplog.acquirewaitcount.intent_exclusiveps
(gauge)
Number of times the oplog lock type acquisition in the Intent Exclusive (IX) mode encountered waits because the locks were held in a conflicting mode.
shown as wait
mongodb.locks.oplog.acquirewaitcount.sharedps
(gauge)
Number of times the oplog lock type acquisition in the Shared (S) mode encountered waits because the locks were held in a conflicting mode.
shown as wait
mongodb.locks.oplog.timeacquiringmicros.intent_exclusiveps
(gauge)
Wait time for the oplog lock type acquisitions in the Intent Exclusive (IX) mode.
shown as fraction
mongodb.locks.oplog.timeacquiringmicros.sharedps
(gauge)
Wait time for the oplog lock type acquisitions in the Shared (S) mode.
shown as fraction
mongodb.mem.mapped
(gauge)
Amount of mapped memory by the database.
shown as mebibyte
mongodb.mem.mappedwithjournal
(gauge)
The amount of mapped memory, including the memory used for journaling.
shown as mebibyte
mongodb.mem.resident
(gauge)
Amount of memory currently used by the database process.
shown as mebibyte
mongodb.mem.virtual
(gauge)
Amount of virtual memory used by the mongod process.
shown as mebibyte
mongodb.metrics.cursor.open.notimeout
(gauge)
Number of open cursors with the option `DBQuery.Option.noTimeout` set to prevent timeout after a period of inactivity.
shown as cursor
mongodb.metrics.cursor.open.pinned
(gauge)
Number of “pinned” open cursors.
shown as cursor
mongodb.metrics.cursor.open.total
(gauge)
Number of cursors that MongoDB is maintaining for clients.
shown as cursor
mongodb.metrics.cursor.timedoutps
(gauge)
Number of cursors that time out, per second.
shown as cursor
mongodb.metrics.document.deletedps
(gauge)
Number of documents deleted per second.
shown as document
mongodb.metrics.document.insertedps
(gauge)
Number of documents inserted per second.
shown as document
mongodb.metrics.document.returnedps
(gauge)
Number of documents returned by queries per second.
shown as document
mongodb.metrics.document.updatedps
(gauge)
Number of documents updated per second.
shown as document
mongodb.metrics.getlasterror.wtime.numps
(gauge)
Number of getLastError operations per second with a specified write concern (i.e. w) that wait for one or more members of a replica set to acknowledge the write operation.
shown as operation
mongodb.metrics.getlasterror.wtime.totalmillisps
(gauge)
Fraction of time (ms/s) that the mongod has spent performing getLastError operations with write concern (i.e. w) that wait for one or more members of a replica set to acknowledge the write operation.
shown as fraction
mongodb.metrics.getlasterror.wtimeoutsps
(gauge)
Number of times per second that write concern operations have timed out as a result of the wtimeout threshold to getLastError
shown as event
mongodb.metrics.operation.fastmodps
(gauge)
Number of update operations per second that neither cause documents to grow nor require updates to the index.
shown as operation
mongodb.metrics.operation.idhackps
(gauge)
Number of queries per second that contain the _id field.
shown as query
mongodb.metrics.operation.scanandorderps
(gauge)
Number of queries per second that return sorted numbers that cannot perform the sort operation using an index.
shown as query
mongodb.metrics.queryexecutor.scannedps
(gauge)
Number of index items scanned per second during queries and query-plan evaluation.
shown as operation
mongodb.metrics.record.movesps
(gauge)
Number of times per second documents move within the on-disk representation of the MongoDB data set.
shown as operation
mongodb.metrics.repl.apply.batches.numps
(gauge)
Number of batches applied across all databases per second.
shown as operation
mongodb.metrics.repl.apply.batches.totalmillisps
(gauge)
Fraction of time (ms/s) the mongod has spent applying operations from the oplog.
shown as fraction
mongodb.metrics.repl.apply.opsps
(gauge)
Number of oplog operations applied per second.
shown as operation
mongodb.metrics.repl.buffer.count
(gauge)
Number of operations in the oplog buffer.
shown as operation
mongodb.metrics.repl.buffer.maxsizebytes
(gauge)
Maximum size of the buffer.
shown as byte
mongodb.metrics.repl.buffer.sizebytes
(gauge)
Current size of the contents of the oplog buffer.
shown as byte
mongodb.metrics.repl.network.bytesps
(gauge)
Amount of data read from the replication sync source per second.
shown as byte
mongodb.metrics.repl.network.getmores.numps
(gauge)
Number of getmore operations per second.
shown as operation
mongodb.metrics.repl.network.getmores.totalmillisps
(gauge)
Fraction of time (ms/s) required to collect data from getmore operations.
shown as fraction
mongodb.metrics.repl.network.opsps
(gauge)
Number of operations read from the replication source per second.
shown as operation
mongodb.metrics.repl.network.readerscreatedps
(gauge)
Number of oplog query processes created per second.
shown as process
mongodb.metrics.ttl.deleteddocumentsps
(gauge)
Number of documents deleted from collections with a ttl index per second.
shown as document
mongodb.metrics.ttl.passesps
(gauge)
Number of times per second the background process removes documents from collections with a ttl index.
shown as operation
mongodb.opcounters.commandps
(gauge)
Total number of commands per second issued to the database.
shown as command
mongodb.opcounters.deleteps
(gauge)
Number of delete operations per second.
shown as operation
mongodb.opcounters.getmoreps
(gauge)
Number of getmore operations per second.
shown as operation
mongodb.opcounters.insertps
(gauge)
Number of insert operations per second.
shown as operation
mongodb.opcounters.queryps
(gauge)
Total number of queries per second.
shown as query
mongodb.opcounters.updateps
(gauge)
Number of update operations per second.
shown as operation
mongodb.opcountersrepl.commandps
(gauge)
Total number of replicated commands issued to the database per second.
shown as command
mongodb.opcountersrepl.deleteps
(gauge)
Number of replicated delete operations per second.
shown as operation
mongodb.opcountersrepl.getmoreps
(gauge)
Number of replicated getmore operations per second.
shown as operation
mongodb.opcountersrepl.insertps
(gauge)
Number of replicated insert operations per second.
shown as operation
mongodb.opcountersrepl.queryps
(gauge)
Total number of replicated queries per second.
shown as query
mongodb.opcountersrepl.updateps
(gauge)
Number of replicated update operations per second.
shown as operation
mongodb.oplog.logsizemb
(gauge)
Total size of the oplog.
shown as mebibyte
mongodb.oplog.timediff
(gauge)
Oplog window: difference between the first and last operation in the oplog.
shown as second
mongodb.oplog.usedsizemb
(gauge)
Total amount of space used by the oplog.
shown as mebibyte
mongodb.replset.health
(gauge)
Member health value of the replica set: conveys if the member is up (i.e. 1) or down (i.e. 0).
shown as
mongodb.replset.replicationlag
(gauge)
Delay between a write operation on the primary and its copy to a secondary.
shown as second
mongodb.stats.datasize
(gauge)
Total size of the data held in this database including the padding factor.
shown as byte
mongodb.stats.indexes
(gauge)
Total number of indexes across all collections in the database.
shown as index
mongodb.stats.indexsize
(gauge)
Total size of all indexes created on this database.
shown as byte
mongodb.stats.objects
(gauge)
Number of objects (documents) in the database across all collections.
shown as object
mongodb.stats.storagesize
(gauge)
Total amount of space allocated to collections in this database for document storage.
shown as byte
mongodb.uptime
(gauge)
Number of seconds that the mongos or mongod process has been active.
shown as second
mongodb.wiredtiger.cache.bytes_currently_in_cache
(gauge)
Size of the data currently in cache.
shown as byte
mongodb.wiredtiger.cache.failed_eviction_of_pages_exceeding_the_in_memory_maximumps
(gauge)
Number of failed eviction of pages that exceeded the in-memory maximum, per second.
shown as page
mongodb.wiredtiger.cache.in_memory_page_splits
(gauge)
In-memory page splits.
shown as split
mongodb.wiredtiger.cache.maximum_bytes_configured
(gauge)
Maximum cache size.
shown as byte
mongodb.wiredtiger.cache.maximum_page_size_at_eviction
(gauge)
Maximum page size at eviction.
shown as byte
mongodb.wiredtiger.cache.modified_pages_evicted
(gauge)
Number of pages, that have been modified, evicted from the cache.
shown as page
mongodb.wiredtiger.cache.pages_currently_held_in_cache
(gauge)
Number of pages currently held in the cache.
shown as page
mongodb.wiredtiger.cache.pages_evicted_by_application_threadsps
(gauge)
Number of page evicted by application threads per second.
shown as page
mongodb.wiredtiger.cache.pages_evicted_exceeding_the_in_memory_maximumps
(gauge)
Number of pages evicted because they exceeded the cache in-memory maximum, per second.
shown as page
mongodb.wiredtiger.cache.tracked_dirty_bytes_in_cache
(gauge)
Size of the dirty data in the cache.
shown as byte
mongodb.wiredtiger.cache.unmodified_pages_evicted
(gauge)
Number of pages, that were not modified, evicted from the cache.
shown as page
mongodb.wiredtiger.concurrenttransactions.read.available
(gauge)
Number of available read tickets (concurrent transactions) remaining.
shown as ticket
mongodb.wiredtiger.concurrenttransactions.read.out
(gauge)
Number of read tickets (concurrent transactions) in use.
shown as ticket
mongodb.wiredtiger.concurrenttransactions.read.totaltickets
(gauge)
Total number of read tickets (concurrent transactions) available.
shown as ticket
mongodb.wiredtiger.concurrenttransactions.write.available
(gauge)
Number of available write tickets (concurrent transactions) remaining.
shown as ticket
mongodb.wiredtiger.concurrenttransactions.write.out
(gauge)
Number of write tickets (concurrent transactions) in use.
shown as ticket
mongodb.wiredtiger.concurrenttransactions.write.totaltickets
(gauge)
Total number of write tickets (concurrent transactions) available.
shown as ticket
mongodb.collection.size
(gauge)
The total size in bytes of the data in the collection plus the size of every indexes on the mongodb.collection.
shown as byte
mongodb.collection.avgObjSize
(gauge)
The size of the average object in the collection in bytes.
shown as byte
mongodb.collection.count
(gauge)
Total number of objects in the collection.
shown as item
mongodb.collection.capped
(gauge)
Whether or not the collection is capped.
shown as record
mongodb.collection.max
(gauge)
Maximum number of documents in a capped collection.
shown as document
mongodb.collection.maxSize
(gauge)
Maximum size of a capped collection in bytes.
shown as byte
mongodb.collection.storageSize
(gauge)
Total storage space allocated to this collection for document storage.
shown as byte
mongodb.collection.nindexes
(gauge)
Total number of indices on the collection.
shown as index
mongodb.collection.indexSizes
(gauge)
Size of index in bytes.
shown as byte