MongoDB
MongoDb database, Collection, MongoDb database cluster running status data Collection.
Config¶
Preconditions¶
-
Already tested version:
- 6.0
- 5.0
- 4.0
- 3.0
- 2.8.0
-
Developed and used MongoDB version
4.4.5; - Write the configuration file in the corresponding directory and then start DataKit to complete the configuration;
- For secure connections using TLS, please configure the response certificate file path and configuration under
## TLS connection configin the configuration file; - If MongoDB has access control enabled, you need to configure the necessary user rights to establish an authorized connection:
# Run MongoDB shell.
$ mongo
# Authenticate as the admin/root user.
> use admin
> db.auth("<admin OR root>", "<YOUR_MONGODB_ADMIN_PASSWORD>")
# Create the user for the DataKit.
> db.createUser({
"user": "datakit",
"pwd": "<YOUR_COLLECT_PASSWORD>",
"roles": [
{ role: "read", db: "admin" },
{ role: "clusterMonitor", db: "admin" },
{ role: "backup", db: "admin" },
{ role: "read", db: "local" }
]
})
More authorization information can refer to official documentation Built-In Roles。
After done with commands above, filling the user and pwd to DataKit configuration file conf.d/db/mongodb.conf.
Collector Configuration¶
Go to the conf.d/samples directory under the DataKit installation directory, copy mongodb.conf.sample and name it mongodb.conf. Examples are as follows:
[[inputs.mongodb]]
## Gathering interval
interval = "10s"
## Specify one single Mongodb server. These server related fields will be ignored when the 'servers' field is not empty.
## connection_format is a string in the standard connection format (mongodb://) or SRV connection format (mongodb+srv://).
connection_format = "mongodb://"
## The host and port.
host_port = "127.0.0.1:27017"
## Username
username = "datakit"
## Password
password = "<PASS>"
## The authentication database to use.
# default_db = "admin"
## A query string that specifies connection specific options as <name>=<value> pairs.
# query_string = "authSource=admin&authMechanism=SCRAM-SHA-256"
## When true, collect replica set stats
gather_replica_set_stats = false
## When true, collect cluster stats
## Note that the query that counts jumbo chunks triggers a COLLSCAN, which may have an impact on performance.
gather_cluster_stats = false
## When true, collect per database stats
gather_per_db_stats = true
## When true, collect per collection stats
gather_per_col_stats = true
## List of db where collections stats are collected, If empty, all dbs are concerned.
col_stats_dbs = []
## When true, collect top command stats.
gather_top_stat = true
## Set true to enable election
election = true
## TLS connection config
# ca_certs = ["/etc/ssl/certs/mongod.cert.pem"]
# cert = "/etc/ssl/certs/mongo.cert.pem"
# cert_key = "/etc/ssl/certs/mongo.key.pem"
# insecure_skip_verify = true
# server_name = ""
## Database Monitoring configuration.
[inputs.mongodb.dbm]
enabled = false
## Databases whose Database Monitoring data are collected.
## Empty means all databases except admin for Query Metrics and Activity.
## Slow Operations auto-discovers at most 100 databases and refreshes the list every 10 minutes.
databases = []
## Query metrics require MongoDB 8.0 or later.
[inputs.mongodb.dbm.query_metrics]
enabled = true
interval = "60s"
## Maximum number of query statistic entries collected per interval.
limit = 10000
## Maximum number of obfuscated query bytes stored in the query_text tag (default: 512, maximum: 1024).
query_text_max_bytes = 512
## Activity captures currently running operations from the $currentOp aggregation stage.
[inputs.mongodb.dbm.activity]
enabled = true
interval = "10s"
## Slow Operations collects completed operations recorded in each database's system.profile collection.
[inputs.mongodb.dbm.slow_operations]
enabled = false
interval = "10s"
max_operations = 1000
## collect mongodb object
[inputs.mongodb.object]
## Set true to enable mongodb object collection
enabled = true
## interval to collect mongodb object which will be greater than collection interval
interval = "600s"
## Mongodb log files and Grok Pipeline files configuration
# [inputs.mongodb.log]
# files = ["/var/log/mongodb/mongod.log"]
# pipeline = "mongod.p"
## Customer tags, if set will be seen with every metric.
# [inputs.mongodb.tags]
# "key1" = "value1"
# "key2" = "value2"
# ...
Once configured, restart DataKit.
The collector can now be turned on by ConfigMap Injection Collector Configuration.
Database Monitoring¶
MongoDB Database Monitoring (DBM) contains Query Metrics, Activity, and Slow Operations collection. dbm.enabled is the parent switch, and databases is the database filter shared by all three collectors. An empty list collects all databases except admin.
[[inputs.mongodb]]
# ... MongoDB connection settings
[inputs.mongodb.dbm]
enabled = true
databases = []
[inputs.mongodb.dbm.query_metrics]
enabled = true
interval = "60s"
limit = 10000
query_text_max_bytes = 512
[inputs.mongodb.dbm.activity]
enabled = true
interval = "10s"
[inputs.mongodb.dbm.slow_operations]
enabled = false
interval = "10s"
max_operations = 1000
Query Metrics and Activity are enabled by default when DBM is enabled. Slow Operations is disabled by default and must be enabled explicitly. All three collectors use the first MongoDB server that initializes successfully.
Query Metrics¶
Query Metrics uses $queryStats to collect execution counts, durations, and scan statistics grouped by query shape.
Prerequisites¶
- MongoDB 8.0 or later is required.
- On self-hosted MongoDB, set
internalQueryStatsRateLimitto a positive integer. The default value0disables Query Stats recording. For example:
The parameter can also be changed dynamically with setParameter. A value of -1 removes the recording rate limit.
Configuration¶
enabled: Query Metrics is enabled by default when DBM is enabled. Set it tofalseto disable Query Metrics independently.interval: Collection interval. The default is60s.limit: Maximum number of Query Stats entries processed per collection interval. The default is10000.query_text_max_bytes: Maximum number of obfuscated query bytes stored in thequery_texttag. The default is512and the maximum is1024. Truncation preserves complete UTF-8 characters and setsquery_truncatedtotrue.
The first collection establishes the delta baseline. Later collections report:
mongodb_dbm_metric: Cumulative values and per-interval deltas prefixed withdelta_.db_query: Obfuscated query commands, reported at most once every 24 hours for eachquery_signature.
Activity¶
Activity uses $currentOp to collect currently running operations.
enabled: Activity is enabled by default when DBM is enabled. Set it tofalseto disable Activity independently.interval: Collection interval. The default is10s.
Each visible operation produces an obfuscated mongodb_dbm_activity log. The same snapshot also produces mongodb_dbm_operation metrics: active_operation_count counts active operations and waiting_for_lock_count counts operations waiting for a lock. These metrics do not represent all MongoDB connections.
Slow Operations¶
Slow Operations incrementally collects completed slow operations from each database's system.profile collection. Enable the MongoDB Profiler in each monitored database, for example:
enabled: Disabled by default. Enable it explicitly together withdbm.enabled.interval: Collection interval. The default is10s.max_operations: Maximum number of slow operations reported per collection interval. The default is1000.
Each slow operation produces one mongodb_dbm_slow_query log. The log timestamp comes from system.profile.ts, the complete obfuscated command is stored in the message field, and tags such as operation, command_type, and plan_summary can be used to aggregate operation counts and durations.
TLS config (self-signed)¶
Use OpenSSL to generate a certificate file for MongoDB TLS configuration to enable server-side encryption and client-side authentication.
- Configure TLS certificates
Install OpenSSL and run the following command:
- Configure MongoDB server-side encryption
Use OpenSSL to generate a certificate-level key file, run the following command and enter the corresponding authentication block information at the command prompt:
sudo openssl req -x509 -newkey rsa:<bits> -days <days> -keyout <mongod.key.pem> -out <mongod.cert.pem> -nodes
bits: rsa key digits, for example, 2048days: expired datemongod.key.pem: key filemongod.cert.pem: CA certificate file
Running the above command generates the cert.pem file and the key.pem file, and we need to merge the block inside the two files to run the following command:
Configure the TLS subentry in the /etc/mongod.config file after merging
Start MongoDB with the configuration file and run the following command:
Start MongoDB from the command line and run the following command:
Copy mongod.cert.pem as mongo.cert.pem to MongoDB client and enable TLS:
- Configuring MongoDB Client Authentication
Use OpenSSL to generate a certificate-level key file and run the following command:
sudo openssl req -x509 -newkey rsa:<bits> -days <days> -keyout <mongod.key.pem> -out <mongod.cert.pem> -nodes
bits: rsa key digits, for example, 2048days: expired datemongo.key.pem: key filemongo.cert.pem: CA certificate file
Merging the block in the mongod.cert.pem and mongod.key.pem files runs the following command:
Copy the mongod.cert.pem file to the MongoDB server and configure the TLS entry in the /etc/mongod.config file.
# Tls config
net:
tls:
mode: requireTLS
certificateKeyFile: </etc/ssl/mongod.pem>
CAFile: </etc/ssl/mongod.cert.pem>
Start MongoDB and run the following command:
Copy mongod.cert.pem for mongo.cert.pem; Copy mongod.pem for mongo.pem to MongoDB client and enable TLS:
mongo --tls --host <mongod_url> --tlsCAFile </etc/ssl/mongo.cert.pem> --tlsCertificateKeyFile </etc/ssl/mongo.pem>
Note:insecure_skip_verify must be true in mongodb.conf configuration when using self-signed certificates.
Metric¶
For all of the following data collections, the global election tags will added automatically, we can add extra tags in [inputs.mongodb.tags] if needed:
mongodb¶
MongoDB serverStatus metrics collected from the configured MongoDB instance.
| Tags & Fields | Description |
|---|---|
| database_instance ( tag) |
MongoDB instance identifier from configured tag database_instance or serverStatus.host. Common tag. |
| host ( tag) |
mongodb host |
| mongod_host ( tag) |
mongodb host with port |
| server ( tag) |
MongoDB server address from the connection string. The value is host:port for standard URIs or the SRV host for mongodb+srv:// URIs. Common tag. |
| active_reads | The number of the active client connections performing read operations. Type: int | (gauge) Unit: count |
| active_writes | The number of active client connections performing write operations. Type: int | (gauge) Unit: count |
| aggregate_command_failed | The number of times that 'aggregate' command failed on this mongod Type: int | (gauge) Unit: count |
| aggregate_command_total | The number of times that 'aggregate' command executed on this mongod. Type: int | (gauge) Unit: count |
| assert_msg | The number of message assertions raised since the MongoDB process started. Check the log file for more information about these messages. Type: int | (gauge) Unit: count |
| assert_regular | The number of regular assertions raised since the MongoDB process started. Check the log file for more information about these messages. Type: int | (gauge) Unit: count |
| assert_rollovers | The number of times that the rollover counters have rolled over since the last time the MongoDB process started. The counters will rollover to zero after 2 30 assertions. Use this value to provide context to the other values in the asserts data structure. Type: int | (gauge) Unit: count |
| assert_user | The number of "user asserts" that have occurred since the last time the MongoDB process started. These are errors that user may generate, such as out of disk space or duplicate key. You can prevent these assertions by fixing a problem with your application or deployment. Check the MongoDB log for more information. Type: int | (gauge) Unit: count |
| assert_warning | Changed in version 4.0. Starting in MongoDB 4.0, the field returns zero 0. In earlier versions, the field returns the number of warnings raised since the MongoDB process started. Type: int | (gauge) Unit: count |
| available_reads | The number of concurrent of read transactions allowed into the WiredTiger storage engine Type: int | (gauge) Unit: count |
| available_writes | The number of concurrent of write transactions allowed into the WiredTiger storage engine Type: int | (gauge) Unit: count |
| commands | The total number of commands issued to the database since the mongod instance last started. opcounters.command counts all commands except the write commands: insert, update, and delete.Type: int | (gauge) Unit: count |
| commands_per_sec | Deprecated, use commands. Type: int | (gauge) Unit: count |
| connections_available | The number of unused incoming connections available. Type: int | (gauge) Unit: count |
| connections_current | The number of incoming connections from clients to the database server . Type: int | (gauge) Unit: count |
| connections_total_created | Count of all incoming connections created to the server. This number includes connections that have since closed. Type: int | (gauge) Unit: count |
| count_command_failed | The number of times that 'count' command failed on this mongod Type: int | (gauge) Unit: count |
| count_command_total | The number of times that 'count' command executed on this mongod Type: int | (gauge) Unit: count |
| cursor_no_timeout | Deprecated, use cursor_no_timeout_count. Type: int | (gauge) Unit: count |
| cursor_no_timeout_count | The number of open cursors with the option DBQuery.Option.noTimeout set to prevent timeout after a period of inactivity Type: int | (gauge) Unit: count |
| cursor_pinned | Deprecated, use cursor_pinned_count. Type: int | (gauge) Unit: count |
| cursor_pinned_count | The number of "pinned" open cursors. Type: int | (gauge) Unit: count |
| cursor_timed_out | Deprecated, use cursor_timed_out_count. Type: int | (gauge) Unit: count |
| cursor_timed_out_count | The total number of cursors that have timed out since the server process started. If this number is large or growing at a regular rate, this may indicate an application error. Type: int | (gauge) Unit: count |
| cursor_total | Deprecated, use cursor_total_count. Type: int | (gauge) Unit: count |
| cursor_total_count | The number of cursors that MongoDB is maintaining for clients. Because MongoDB exhausts unused cursors, typically this value small or zero. However, if there is a queue, stale tailable cursors, or a large number of operations this value may rise. Type: int | (gauge) Unit: count |
| delete_command_failed | The number of times that 'delete' command failed on this mongod Type: int | (gauge) Unit: count |
| delete_command_total | The number of times that 'delete' command executed on this mongod Type: int | (gauge) Unit: count |
| deletes | The total number of delete operations since the mongod instance last started. Type: int | (gauge) Unit: count |
| deletes_per_sec | Deprecated, use deletes. Type: int | (gauge) Unit: count |
| distinct_command_failed | The number of times that 'distinct' command failed on this mongod Type: int | (gauge) Unit: count |
| distinct_command_total | The number of times that 'distinct' command executed on this mongod Type: int | (gauge) Unit: count |
| document_deleted | The total number of documents deleted. Type: int | (gauge) Unit: count |
| document_inserted | The total number of documents inserted. Type: int | (gauge) Unit: count |
| document_returned | The total number of documents returned by queries. Type: int | (gauge) Unit: count |
| document_updated | The total number of documents updated. Type: int | (gauge) Unit: count |
| find_and_modify_command_failed | The number of times that 'find' and 'modify' commands failed on this mongod Type: int | (gauge) Unit: count |
| find_and_modify_command_total | The number of times that 'find' and 'modify' commands executed on this mongod Type: int | (gauge) Unit: count |
| find_command_failed | The number of times that 'find' command failed on this mongod Type: int | (gauge) Unit: count |
| find_command_total | The number of times that 'find' command executed on this mongod Type: int | (gauge) Unit: count |
| flushes | The number of transaction checkpoints Type: int | (gauge) Unit: count |
| flushes_per_sec | Deprecated, use flushes. Type: int | (gauge) Unit: count |
| flushes_total_time_ns | The transaction checkpoint total time (ms)" Type: int | (gauge) Unit: count |
| get_more_command_failed | The number of times that 'get more' command failed on this mongod Type: int | (gauge) Unit: count |
| get_more_command_total | The number of times that 'get more' command executed on this mongod Type: int | (gauge) Unit: count |
| getmores | The total number of getMore operations since the mongod instance last started. This counter can be high even if the query count is low. Secondary nodes send getMore operations as part of the replication process.Type: int | (gauge) Unit: count |
| getmores_per_sec | Deprecated, use getmores Type: int | (gauge) Unit: count |
| insert_command_failed | The number of times that 'insert' command failed on this mongod Type: int | (gauge) Unit: count |
| insert_command_total | The number of times that 'insert' command executed on this mongod Type: int | (gauge) Unit: count |
| inserts | The total number of insert operations received since the mongod instance last started. Type: int | (gauge) Unit: count |
| inserts_per_sec | Deprecated, use inserts. Type: int | (gauge) Unit: count |
| jumbo_chunks | Count jumbo flags in cluster chunk. Type: int | (gauge) Unit: count |
| mapped_megabytes | Mapped megabytes. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| net_in_bytes | Deprecated, use net_out_bytes_count. Type: int | (gauge) Unit: count |
| net_in_bytes_count | The total number of bytes that the server has received over network connections initiated by clients or other mongod instances. Type: int | (gauge) Unit: count |
| net_out_bytes | Deprecated, use net_out_bytes_count. Type: int | (gauge) Unit: count |
| net_out_bytes_count | The total number of bytes that the server has sent over network connections initiated by clients or other mongod instances. Type: int | (gauge) Unit: count |
| non-mapped_megabytes | Non mapped megabytes. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| open_connections | The number of incoming connections from clients to the database server. Type: int | (gauge) Unit: count |
| operation_scan_and_order | The total number of queries that return sorted numbers that cannot perform the sort operation using an index. Type: int | (gauge) Unit: count |
| operation_write_conflicts | The total number of queries that encountered write conflicts. Type: int | (gauge) Unit: count |
| page_faults | The total number of page faults. Type: int | (gauge) Unit: count |
| page_faults_per_sec | Page Faults/sec is the average number of pages faulted per second. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| percent_cache_dirty | Size in bytes of the dirty data in the cache. This value should be less than the bytes currently in the cache value. Type: float | (gauge) Unit: count |
| percent_cache_used | Size in byte of the data currently in cache. This value should not be greater than the maximum bytes configured value. Type: float | (gauge) Unit: count |
| queries | The total number of queries received since the mongod instance last started. Type: int | (gauge) Unit: count |
| queries_per_sec | Deprecated, use queries. Type: int | (gauge) Unit: count |
| queued_reads | 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. Type: int | (gauge) Unit: count |
| queued_writes | 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. Type: int | (gauge) Unit: count |
| repl_apply_batches_num | The total number of batches applied across all databases. Type: int | (gauge) Unit: count |
| repl_apply_batches_total_millis | The total amount of time in milliseconds the mongod has spent applying operations from the oplog. Type: int | (gauge) Unit: count |
| repl_apply_ops | The total number of oplog operations applied. metrics.repl.apply.ops is incremented after each operation. Type: int | (gauge) Unit: count |
| repl_buffer_count | The current number of operations in the oplog buffer. Type: int | (gauge) Unit: count |
| repl_buffer_size_bytes | The current size of the contents of the oplog buffer. Type: int | (gauge) Unit: count |
| repl_commands | The total number of replicated commands issued to the database since the mongod instance last started. Type: int | (gauge) Unit: count |
| repl_commands_per_sec | Deprecated, use repl_commands. Type: int | (gauge) Unit: count |
| repl_deletes | The total number of replicated delete operations since the mongod instance last started. Type: int | (gauge) Unit: count |
| repl_deletes_per_sec | Deprecated, use repl_deletes. Type: int | (gauge) Unit: count |
| repl_executor_pool_in_progress_count | The number of replication tasks that are currently being executed by the executor pool. Type: int | (gauge) Unit: count |
| repl_executor_queues_network_in_progress | The number of network-related replication tasks that are currently being processed by the executor queues. Type: int | (gauge) Unit: count |
| repl_executor_queues_sleepers | The number of replication tasks in the executor queues that are currently in a sleeping state. Type: int | (gauge) Unit: count |
| repl_executor_unsignaled_events | The number of events related to the replication executor that have not yet been signaled. Type: int | (gauge) Unit: count |
| repl_getmores | The total number of replicated getmore operations since the mongod instance last started. Type: int | (gauge) Unit: count |
| repl_getmores_per_sec | Deprecated, use repl_getmores. Type: int | (gauge) Unit: count |
| repl_inserts | The total number of replicated insert operations since the mongod instance last started. Type: int | (gauge) Unit: count |
| repl_inserts_per_sec | Deprecated, use repl_inserts. Type: int | (gauge) Unit: count |
| repl_lag | Delay between a write operation on the primary and its copy to a secondary. Type: int | (gauge) Unit: count |
| repl_network_bytes | The total amount of data read from the replication sync source. Type: int | (gauge) Unit: count |
| repl_network_getmores_num | The total number of getmore operations, which are operations that request an additional set of operations from the replication sync source. Type: int | (gauge) Unit: count |
| repl_network_getmores_total_millis | The total amount of time required to collect data from getmore operations. Type: int | (gauge) Unit: count |
| repl_network_ops | The total number of operations read from the replication source. Type: int | (gauge) Unit: count |
| repl_queries | The total number of replicated queries since the mongod instance last started. Type: int | (gauge) Unit: count |
| repl_queries_per_sec | Deprecated, use repl_queries. Type: int | (gauge) Unit: count |
| repl_state | The node state of replication member. Type: int | (gauge) Unit: count |
| repl_updates | The total number of replicated update operations since the mongod instance last started. Type: int | (gauge) Unit: count |
| repl_updates_per_sec | Deprecated, use repl_updates. Type: int | (gauge) Unit: count |
| resident_megabytes | The value of mem.resident is roughly equivalent to the amount of RAM, in MiB, currently used by the database process. Type: int | (gauge) Unit: count |
| storage_freelist_search_bucket_exhausted | The number of times that mongod has checked the free list without finding a suitably large record allocation. Type: int | (gauge) Unit: count |
| storage_freelist_search_requests | The number of times mongod has searched for available record allocations. Type: int | (gauge) Unit: count |
| storage_freelist_search_scanned | The number of available record allocations mongod has searched. Type: int | (gauge) Unit: count |
| tcmalloc_central_cache_free_bytes | Number of free bytes in the central cache that have been assigned to size classes. They always count towards virtual memory usage, and unless the underlying memory is swapped. Type: int | (gauge) Unit: count |
| tcmalloc_current_allocated_bytes | Number of bytes currently allocated by application. Type: int | (gauge) Unit: count |
| tcmalloc_current_total_thread_cache_bytes | Number of bytes used across all thread caches. Type: int | (gauge) Unit: count |
| tcmalloc_heap_size | Number of bytes in the heap. Type: int | (gauge) Unit: count |
| tcmalloc_max_total_thread_cache_bytes | Upper limit on total number of bytes stored across all per-thread caches. Default: 16MB. Type: int | (gauge) Unit: count |
| tcmalloc_pageheap_commit_count | Number of virtual memory commits. Type: int | (gauge) Unit: count |
| tcmalloc_pageheap_committed_bytes | Bytes committed, always <= system_bytes_. Type: int | (gauge) Unit: count |
| tcmalloc_pageheap_decommit_count | Number of virtual memory de-commits. Type: int | (gauge) Unit: count |
| tcmalloc_pageheap_free_bytes | Number of bytes in free, mapped pages in page heap. Type: int | (gauge) Unit: count |
| tcmalloc_pageheap_reserve_count | Number of virtual memory reserves. Type: int | (gauge) Unit: count |
| tcmalloc_pageheap_scavenge_count | Number of times scavaged flush pages. Type: int | (gauge) Unit: count |
| tcmalloc_pageheap_total_commit_bytes | Bytes committed in lifetime of process. Type: int | (gauge) Unit: count |
| tcmalloc_pageheap_total_decommit_bytes | Bytes de-committed in lifetime of process. Type: int | (gauge) Unit: count |
| tcmalloc_pageheap_total_reserve_bytes | Number of virtual memory reserves. Type: int | (gauge) Unit: count |
| tcmalloc_pageheap_unmapped_bytes | Total bytes on returned free lists. Type: int | (gauge) Unit: count |
| tcmalloc_spinlock_total_delay_ns | The total time (in nanoseconds) threads have been delayed while waiting for spinlocks in TCMalloc. Type: int | (gauge) Unit: count |
| tcmalloc_thread_cache_free_bytes | Bytes in thread caches. Type: int | (gauge) Unit: count |
| tcmalloc_total_free_bytes | Total bytes on normal free lists. Type: int | (gauge) Unit: count |
| tcmalloc_transfer_cache_free_bytes | Bytes in central transfer cache. Type: int | (gauge) Unit: count |
| total_available | The number of connections available from the mongos to the config servers, replica sets, and standalone mongod instances in the cluster. Type: int | (gauge) Unit: count |
| total_created | The number of connections the mongos has ever created to other members of the cluster. Type: int | (gauge) Unit: count |
| total_docs_scanned | The total number of index items scanned during queries and query-plan evaluation. Type: int | (gauge) Unit: count |
| total_in_use | Reports the total number of outgoing connections from the current mongod/mongos instance to other members of the sharded cluster or replica set that are currently in use. Type: int | (gauge) Unit: count |
| total_keys_scanned | The total number of index items scanned during queries and query-plan evaluation. Type: int | (gauge) Unit: count |
| total_refreshing | Reports the total number of outgoing connections from the current mongod/mongos instance to other members of the sharded cluster or replica set that are currently being refreshed. Type: int | (gauge) Unit: count |
| total_tickets_reads | A document that returns information on the number of concurrent of read transactions allowed into the WiredTiger storage engine. Type: int | (gauge) Unit: count |
| total_tickets_writes | A document that returns information on the number of concurrent of write transactions allowed into the WiredTiger storage engine. Type: int | (gauge) Unit: count |
| ttl_deletes | The total number of documents deleted from collections with a ttl index. Type: int | (gauge) Unit: count |
| ttl_deletes_per_sec | Deprecated, use ttl_deletes. Type: int | (gauge) Unit: count |
| ttl_passes | The number of times the background process removes documents from collections with a ttl index. Type: int | (gauge) Unit: count |
| ttl_passes_per_sec | Deprecated, use ttl_passes. Type: int | (gauge) Unit: count |
| update_command_failed | The number of times that 'update' command failed on this mongod Type: int | (gauge) Unit: count |
| update_command_total | The number of times that 'update' command executed on this mongod Type: int | (gauge) Unit: count |
| updates | The total number of update operations received since the mongod instance last started. Type: int | (gauge) Unit: count |
| updates_per_sec | Deprecated, use updates. Type: int | (gauge) Unit: count |
| uptime_ns | The total upon time of mongod in nano seconds. Type: int | (gauge) Unit: count |
| vsize_megabytes | mem.virtual displays the quantity, in MiB, of virtual memory used by the mongod process. Type: int | (gauge) Unit: count |
| wtcache_app_threads_page_read_count | The number of pages read by application threads from the WiredTiger cache. Type: int | (gauge) Unit: count |
| wtcache_app_threads_page_read_time | The total time application threads spend reading pages from the WiredTiger cache. Type: int | (gauge) Unit: count |
| wtcache_app_threads_page_write_count | The number of pages written by application threads to the WiredTiger cache. Type: int | (gauge) Unit: count |
| wtcache_bytes_read_into | The total number of bytes read into the WiredTiger cache. Type: int | (gauge) Unit: count |
| wtcache_bytes_written_from | The total number of bytes written from the WiredTiger cache. Type: int | (gauge) Unit: count |
| wtcache_current_bytes | The current number of bytes being used in the WiredTiger cache. Type: int | (gauge) Unit: count |
| wtcache_internal_pages_evicted | The number of internal pages evicted from the WiredTiger cache. Type: int | (gauge) Unit: count |
| wtcache_max_bytes_configured | Maximum cache size. Type: int | (gauge) Unit: count |
| wtcache_modified_pages_evicted | The number of modified pages evicted from the WiredTiger cache. Type: int | (gauge) Unit: count |
| wtcache_pages_evicted_by_app_thread | The number of pages evicted from the WiredTiger cache by application threads. Type: int | (gauge) Unit: count |
| wtcache_pages_queued_for_eviction | The current number of pages in the WiredTiger cache that are queued for eviction. Type: int | (gauge) Unit: count |
| wtcache_pages_read_into | Number of pages read into the cache. Type: int | (gauge) Unit: count |
| wtcache_pages_requested_from | Number of pages request from the cache. Type: int | (gauge) Unit: count |
| wtcache_pages_written_from | Pages written from cache Type: int | (gauge) Unit: count |
| wtcache_server_evicting_pages | The current number of pages in the WiredTiger cache that are being evicted by the server. Type: int | (gauge) Unit: count |
| wtcache_tracked_dirty_bytes | The total number of bytes in the WiredTiger cache that are tracked as dirty. Type: int | (gauge) Unit: count |
| wtcache_unmodified_pages_evicted | Main statistics for page eviction. Type: int | (gauge) Unit: count |
| wtcache_worker_thread_evictingpages | The number of pages being evicted from the WiredTiger cache by worker threads. Type: int | (gauge) Unit: count |
mongodb_db_stats¶
MongoDB stats measurement. Some metrics may not appear depending on the MongoDB version or DB running status.
| Tags & Fields | Description |
|---|---|
| database_instance ( tag) |
MongoDB instance identifier from configured tag database_instance or serverStatus.host. Common tag. |
| db_name ( tag) |
database name |
| host ( tag) |
mongodb host |
| mongod_host ( tag) |
mongodb host with port |
| server ( tag) |
MongoDB server address from the connection string. The value is host:port for standard URIs or the SRV host for mongodb+srv:// URIs. Common tag. |
| avg_obj_size | The average size of each document in bytes. Type: float | (gauge) Unit: count |
| collections | Contains a count of the number of collections in that database. Type: int | (gauge) Unit: count |
| data_size | The total size of the uncompressed data held in this database. The dataSize decreases when you remove documents. Type: int | (gauge) Unit: count |
| index_size | The total size of all indexes created on this database. Type: int | (gauge) Unit: count |
| indexes | Contains a count of the total number of indexes across all collections in the database. Type: int | (gauge) Unit: count |
| mapped_megabytes | Mapped megabytes. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| non-mapped_megabytes | Non mapped megabytes. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| objects | Contains a count of the number of objects (i.e. documents) in the database across all collections. Type: int | (gauge) Unit: count |
| ok | Command execute state. Type: int | (gauge) Unit: count |
| page_faults_per_sec | Page Faults/sec is the average number of pages faulted per second. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| percent_cache_dirty | Size in bytes of the dirty data in the cache. This value should be less than the bytes currently in the cache value. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| percent_cache_used | Size in byte of the data currently in cache. This value should not be greater than the maximum bytes configured value. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| storage_size | The total amount of space allocated to collections in this database for document storage. Type: int | (gauge) Unit: count |
| wtcache_app_threads_page_read_count | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_app_threads_page_read_time | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_app_threads_page_write_count | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_bytes_read_into | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_bytes_written_from | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_current_bytes | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_internal_pages_evicted | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_max_bytes_configured | Maximum cache size. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_modified_pages_evicted | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_pages_evicted_by_app_thread | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_pages_queued_for_eviction | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_pages_read_into | Number of pages read into the cache. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_pages_requested_from | Number of pages request from the cache. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_pages_written_from | Pages written from cache. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_server_evicting_pages | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_tracked_dirty_bytes | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_unmodified_pages_evicted | Main statistics for page eviction. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_worker_thread_evictingpages | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
mongodb_col_stats¶
MongoDB collection measurement. Some metrics may not appear depending on the MongoDB version or DB running status.
| Tags & Fields | Description |
|---|---|
| collection ( tag) |
collection name |
| database_instance ( tag) |
MongoDB instance identifier from configured tag database_instance or serverStatus.host. Common tag. |
| db_name ( tag) |
database name |
| host ( tag) |
mongodb host |
| mongod_host ( tag) |
mongodb host with port |
| server ( tag) |
MongoDB server address from the connection string. The value is host:port for standard URIs or the SRV host for mongodb+srv:// URIs. Common tag. |
| avg_obj_size | The average size of an object in the collection. Type: float | (gauge) Unit: count |
| count | The number of objects or documents in this collection. Type: int | (gauge) Unit: count |
| mapped_megabytes | Mapped megabytes. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| non-mapped_megabytes | Non mapped megabytes. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| ok | Command execute state. Type: int | (gauge) Unit: count |
| page_faults_per_sec | Page Faults/sec is the average number of pages faulted per second. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| percent_cache_dirty | Size in bytes of the dirty data in the cache. This value should be less than the bytes currently in the cache value. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| percent_cache_used | Size in byte of the data currently in cache. This value should not be greater than the maximum bytes configured value. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| size | The total uncompressed size in memory of all records in a collection. Type: int | (gauge) Unit: count |
| storage_size | The total amount of storage allocated to this collection for document storage. Type: int | (gauge) Unit: count |
| total_index_size | The total size of all indexes. Type: int | (gauge) Unit: count |
| wtcache_app_threads_page_read_count | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_app_threads_page_read_time | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_app_threads_page_write_count | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_bytes_read_into | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_bytes_written_from | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_current_bytes | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_internal_pages_evicted | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_max_bytes_configured | Maximum cache size. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_modified_pages_evicted | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_pages_evicted_by_app_thread | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_pages_queued_for_eviction | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_pages_read_into | Number of pages read into the cache. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_pages_requested_from | Number of pages request from the cache. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_pages_written_from | Pages written from cache. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_server_evicting_pages | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_tracked_dirty_bytes | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_unmodified_pages_evicted | Main statistics for page eviction. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_worker_thread_evictingpages | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
mongodb_shard_stats¶
MongoDB shard measurement. Some metrics may not appear depending on the MongoDB version or DB running status.
| Tags & Fields | Description |
|---|---|
| database_instance ( tag) |
MongoDB instance identifier from configured tag database_instance or serverStatus.host. Common tag. |
| host ( tag) |
mongodb host |
| mongod_host ( tag) |
mongodb host with port |
| server ( tag) |
MongoDB server address from the connection string. The value is host:port for standard URIs or the SRV host for mongodb+srv:// URIs. Common tag. |
| available | The number of connections available for this host to connect to the mongos. Type: int | (gauge) Unit: count |
| created | The number of connections the host has ever created to connect to the mongos. Type: int | (gauge) Unit: count |
| in_use | Reports the total number of outgoing connections from the current mongod/mongos instance to other members of the sharded cluster or replica set that are currently in use. Type: int | (gauge) Unit: count |
| refreshing | Reports the total number of outgoing connections from the current mongod/mongos instance to other members of the sharded cluster or replica set that are currently being refreshed. Type: int | (gauge) Unit: count |
mongodb_top_stats¶
MongoDB top measurement. Some metrics may not appear depending on the MongoDB version or DB running status.
| Tags & Fields | Description |
|---|---|
| collection ( tag) |
collection name |
| database_instance ( tag) |
MongoDB instance identifier from configured tag database_instance or serverStatus.host. Common tag. |
| host ( tag) |
mongodb host |
| mongod_host ( tag) |
mongodb host with port |
| server ( tag) |
MongoDB server address from the connection string. The value is host:port for standard URIs or the SRV host for mongodb+srv:// URIs. Common tag. |
| commands_count | The total number of "command" event issues. Type: int | (gauge) Unit: count |
| commands_time | The amount of time in microseconds that "command" costs. Type: int | (gauge) Unit: count |
| get_more_count | The total number of getmore event issues.Type: int | (gauge) Unit: count |
| get_more_time | The amount of time in microseconds that getmore costs.Type: int | (gauge) Unit: count |
| insert_count | The total number of "insert" event issues. Type: int | (gauge) Unit: count |
| insert_time | The amount of time in microseconds that "insert" costs. Type: int | (gauge) Unit: count |
| mapped_megabytes | Mapped megabytes. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| non-mapped_megabytes | Non mapped megabytes. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| page_faults_per_sec | Page Faults/sec is the average number of pages faulted per second. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| percent_cache_dirty | Size in bytes of the dirty data in the cache. This value should be less than the bytes currently in the cache value. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| percent_cache_used | Size in byte of the data currently in cache. This value should not be greater than the maximum bytes configured value. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| queries_count | The total number of "queries" event issues. Type: int | (gauge) Unit: count |
| queries_time | The amount of time in microseconds that "queries" costs. Type: int | (gauge) Unit: count |
| read_lock_count | The total number of "readLock" event issues. Type: int | (gauge) Unit: count |
| read_lock_time | The amount of time in microseconds that "readLock" costs. Type: int | (gauge) Unit: count |
| remove_count | The total number of "remove" event issues. Type: int | (gauge) Unit: count |
| remove_time | The amount of time in microseconds that "remove" costs. Type: int | (gauge) Unit: count |
| total_count | The total number of "total" event issues. Type: int | (gauge) Unit: count |
| total_time | The amount of time in microseconds that "total" costs. Type: int | (gauge) Unit: count |
| update_count | The total number of "update" event issues. Type: int | (gauge) Unit: count |
| update_time | The amount of time in microseconds that "update" costs. Type: int | (gauge) Unit: count |
| write_lock_count | The total number of "writeLock" event issues. Type: int | (gauge) Unit: count |
| write_lock_time | The amount of time in microseconds that "writeLock" costs. Type: int | (gauge) Unit: count |
| wtcache_app_threads_page_read_count | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_app_threads_page_read_time | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_app_threads_page_write_count | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_bytes_read_into | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_bytes_written_from | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_current_bytes | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_internal_pages_evicted | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_max_bytes_configured | Maximum cache size. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_modified_pages_evicted | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_pages_evicted_by_app_thread | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_pages_queued_for_eviction | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_pages_read_into | Number of pages read into the cache. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_pages_requested_from | Number of pages request from the cache. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_pages_written_from | Pages written from cache. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_server_evicting_pages | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_tracked_dirty_bytes | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_unmodified_pages_evicted | Main statistics for page eviction. (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
| wtcache_worker_thread_evictingpages | (Existed in 3.0 and earlier version) Type: int | (gauge) Unit: count |
mongodb_dbm_metric¶
MongoDB Query Metrics collected from $queryStats. Original fields are cumulative values and delta_ fields are changes during the collection interval.
| Tags & Fields | Description |
|---|---|
| collection ( tag) |
Collection name from the query namespace. |
| command_type ( tag) |
MongoDB command type, such as find or aggregate. |
| database_instance ( tag) |
MongoDB instance identifier. |
| database_name ( tag) |
Database name from the query namespace. |
| database_type ( tag) |
Database type. The value is MongoDB. |
| mongod_host ( tag) |
MongoDB server host. |
| normalized_query_hash ( tag) |
Hash computed from the complete obfuscated MongoDB command for linking DBM data. |
| query_shape_hash ( tag) |
MongoDB-native hash of the query shape. |
| query_signature ( tag) |
xxhash signature generated from database_name, collection, and MongoDB query_shape_hash. |
| query_text ( tag) |
A configurable UTF-8-safe prefix of the obfuscated MongoDB command. |
| query_truncated ( tag) |
Whether query_text was truncated to the configured byte limit. |
| server ( tag) |
MongoDB server address. |
| bytes_read_sum | Cumulative bytes read returned by MongoDB. Type: int | (gauge) Unit: digital,B |
| cpu_nanos_sum | Cumulative CPU time returned by MongoDB. Type: int | (gauge) Unit: time,ns |
| delta_bytes_read_sum | Change in bytes read during the collection interval. Type: int | (count) Unit: digital,B |
| delta_cpu_nanos_sum | Change in CPU time during the collection interval. Type: int | (count) Unit: time,ns |
| delta_docs_examined_sum | Change in documents examined during the collection interval. Type: int | (count) Unit: count |
| delta_docs_returned_sum | Change in documents returned during the collection interval. Type: int | (count) Unit: count |
| delta_exec_count | Change in query executions during the collection interval. Type: int | (count) Unit: count |
| delta_first_response_exec_micros_sum | Change in time to first response during the collection interval. Type: int | (count) Unit: time,μs |
| delta_has_sort_stage_count | Change in executions that used a sort stage during the collection interval. Type: int | (count) Unit: count |
| delta_keys_examined_sum | Change in index keys examined during the collection interval. Type: int | (count) Unit: count |
| delta_read_time_micros_sum | Change in time spent reading data during the collection interval. Type: int | (count) Unit: time,μs |
| delta_total_exec_micros_sum | Change in query execution time during the collection interval. Type: int | (count) Unit: time,μs |
| delta_used_disk_count | Change in executions that used disk during the collection interval. Type: int | (count) Unit: count |
| delta_working_time_millis_sum | Change in working time during the collection interval. Type: int | (count) Unit: time,ms |
| docs_examined_sum | Cumulative number of documents examined returned by MongoDB. Type: int | (gauge) Unit: count |
| docs_returned_sum | Cumulative number of documents returned by MongoDB. Type: int | (gauge) Unit: count |
| exec_count | Cumulative number of query executions returned by MongoDB. Type: int | (gauge) Unit: count |
| first_response_exec_micros_sum | Cumulative time to first response returned by MongoDB. Type: int | (gauge) Unit: time,μs |
| has_sort_stage_count | Cumulative number of executions that used a sort stage returned by MongoDB. Type: int | (gauge) Unit: count |
| keys_examined_sum | Cumulative number of index keys examined returned by MongoDB. Type: int | (gauge) Unit: count |
| read_time_micros_sum | Cumulative time spent reading data returned by MongoDB. Type: int | (gauge) Unit: time,μs |
| total_exec_micros_sum | Cumulative query execution time returned by MongoDB. Type: int | (gauge) Unit: time,μs |
| used_disk_count | Cumulative number of executions that used disk returned by MongoDB. Type: int | (gauge) Unit: count |
| working_time_millis_sum | Cumulative working time returned by MongoDB. Type: int | (gauge) Unit: time,ms |
mongodb_dbm_operation¶
MongoDB active operations aggregated from each $currentOp Activity snapshot.
| Tags & Fields | Description |
|---|---|
| application ( tag) |
Client application name. |
| client_address ( tag) |
Client host address without the ephemeral port. |
| command_type ( tag) |
MongoDB command type, such as find, aggregate, or getMore. |
| database_instance ( tag) |
MongoDB instance identifier. |
| database_name ( tag) |
Database name of the active operations. |
| database_type ( tag) |
Database type. The value is MongoDB. |
| mongod_host ( tag) |
MongoDB server host. |
| namespace ( tag) |
MongoDB namespace, usually database.collection. |
| operation ( tag) |
MongoDB operation type reported by $currentOp. |
| server ( tag) |
MongoDB server address. |
| shard ( tag) |
Shard executing the active operations. |
| user ( tag) |
First effective MongoDB user of the active operations. |
| active_operation_count | Number of active operations in the current Activity snapshot for this tag group. Type: int | (gauge) Unit: count |
| waiting_for_lock_count | Number of active operations waiting for a lock in the current Activity snapshot. Type: int | (gauge) Unit: count |
collector¶
Shared collector availability metric emitted by multiple collectors to report whether the target was successfully scraped.
| Tags & Fields | Description |
|---|---|
| instance ( tag) |
Server addr of the instance |
| job ( tag) |
Server name of the instance |
| up | Whether the collector successfully scraped the target during the last collection cycle: 1 means true and 0 means false. Type: int | (gauge) Unit: bool |
Object¶
database¶
MongoDB object metrics.
| Tags & Fields | Description |
|---|---|
| database_instance ( tag) |
MongoDB instance identifier from configured tag database_instance or serverStatus.host. Common tag. |
| database_type ( tag) |
The type of the database. The value is MongoDB |
| host ( tag) |
The hostname of the MongoDB server |
| name ( tag) |
The object identifier. The value is <server>-<database_instance> when server and database_instance are different, otherwise server. |
| port ( tag) |
The port of the MongoDB server |
| server ( tag) |
MongoDB server address from the connection string. The value is host:port for standard URIs or the SRV host for mongodb+srv:// URIs. Common tag. |
| version ( tag) |
The version of the MongoDB server |
| avg_query_time | The average time taken by a query to execute Type: float Unit: timeStamp,usec |
| message | MongoDB startup/configuration settings from the parsed getCmdLineOpts output. Type: string Unit: - |
| qps | The number of operations executed by the database per second. Type: float Unit: gauge |
| uptime | The number of seconds that the server has been up Type: int Unit: time,s |
message Metric Field Structure¶
The message field contains MongoDB startup/configuration settings collected from the parsed section of the getCmdLineOpts admin command. It does not include command-line argv, connection counters, or database statistics. The exact keys depend on the MongoDB startup options and configuration file. Its basic structure is as follows:
{
"setting": {
"net": {
"port": 27017,
"bindIp": "127.0.0.1"
},
"storage": {
"dbPath": "/var/lib/mongodb",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/var/log/mongodb/mongod.log"
}
}
}
db_query¶
MongoDB DBM query objects containing the obfuscated command linked to Query Metrics by query_signature and reported at most once every 24 hours per signature.
| Tags & Fields | Description |
|---|---|
| collection ( tag) |
Collection name from the query namespace. |
| command_type ( tag) |
MongoDB command type, such as find or aggregate. |
| database_instance ( tag) |
MongoDB instance identifier. |
| database_name ( tag) |
Database name from the query namespace. |
| database_type ( tag) |
Database type. The value is MongoDB. |
| mongod_host ( tag) |
MongoDB server host. |
| name ( tag) |
Object identity built from server, database_instance, and query_signature. |
| normalized_query_hash ( tag) |
Hash computed from the complete obfuscated MongoDB command for linking DBM data. |
| query_shape_hash ( tag) |
MongoDB-native hash of the query shape. |
| query_signature ( tag) |
xxhash signature generated from database_name, collection, and MongoDB query_shape_hash. |
| server ( tag) |
MongoDB server address. |
| message | Obfuscated MongoDB command reconstructed from the query shape. Type: string | (string) Unit: N/A |
Logging¶
The following DBM Activity measurement is collected as logs:
mongodb_dbm_activity¶
MongoDB operations that were active when the $currentOp snapshot was collected.
| Tags & Fields | Description |
|---|---|
| activity_type ( tag) |
MongoDB current operation type. |
| application ( tag) |
Client application name. |
| collection ( tag) |
Collection name of the operation. |
| command_type ( tag) |
MongoDB command type, such as find, aggregate, or getMore. |
| database_instance ( tag) |
MongoDB instance identifier. |
| database_name ( tag) |
Database name of the operation. |
| database_type ( tag) |
Database type. The value is MongoDB. |
| mongod_host ( tag) |
MongoDB server host. |
| normalized_query_hash ( tag) |
Hash of the canonical obfuscated command used to link activity to MongoDB Query Metrics. |
| operation ( tag) |
MongoDB operation name. |
| query_shape_hash ( tag) |
MongoDB-native hash of the query shape. |
| query_signature ( tag) |
xxhash signature generated from database_name, collection, and MongoDB query_shape_hash. |
| server ( tag) |
MongoDB server address. |
| shard ( tag) |
Shard that is executing the operation. |
| user ( tag) |
First effective MongoDB user of the operation. |
| active | Whether the operation is active. Type: bool | (bool) Unit: N/A |
| client | JSON document containing client host, driver, operating system, and platform. Type: string | (string) Unit: N/A |
| current_op_time | Current operation timestamp reported by MongoDB. Type: string | (string) Unit: N/A |
| cursor | JSON document containing cursor details and the obfuscated originating command. Type: string | (string) Unit: N/A |
| description | MongoDB operation description. Type: string | (string) Unit: N/A |
| flow_control_stats | JSON document containing flow-control statistics. Type: string | (string) Unit: N/A |
| lock_stats | JSON document containing lock acquisition statistics. Type: string | (string) Unit: N/A |
| locks | JSON document containing lock modes held by the operation. Type: string | (string) Unit: N/A |
| logical_session_id | JSON document containing the hexadecimal logical session identifier. Type: string | (string) Unit: N/A |
| message | Complete obfuscated MongoDB command. Type: string | (string) Unit: N/A |
| microsecs_running | Elapsed time of the in-flight operation. Type: int | (gauge) Unit: time,μs |
| namespace | MongoDB namespace of the operation. Type: string | (string) Unit: N/A |
| num_yields | Number of times the operation yielded. Type: int | (gauge) Unit: count |
| operation_id | MongoDB operation identifier. Type: string | (string) Unit: N/A |
| plan_summary | Summary of the query execution plan reported by $currentOp. Type: string | (string) Unit: N/A |
| prepare_read_conflicts | Number of prepare read conflicts encountered by the operation. Type: int | (gauge) Unit: count |
| query_framework | Query execution framework reported by MongoDB. Type: string | (string) Unit: N/A |
| query_truncated | Whether MongoDB reported the command as truncated. Type: string | (string) Unit: N/A |
| transaction | JSON document containing transaction timing and identifiers. Type: string | (string) Unit: N/A |
| waiting_for_flow_control | Whether the operation is waiting for flow control. Type: bool | (bool) Unit: N/A |
| waiting_for_latch | JSON document describing the latch wait. Type: string | (string) Unit: N/A |
| waiting_for_lock | Whether the operation is waiting for a lock. Type: bool | (bool) Unit: N/A |
| write_conflicts | Number of write conflicts encountered by the operation. Type: int | (gauge) Unit: count |
mongodb_dbm_slow_query¶
MongoDB completed slow operations collected from each database's system.profile collection.
| Tags & Fields | Description |
|---|---|
| application ( tag) |
Client application name. |
| collection ( tag) |
Collection name of the slow operation. |
| command_type ( tag) |
MongoDB command type, such as find, aggregate, update, or getMore. |
| database_instance ( tag) |
MongoDB instance identifier. |
| database_name ( tag) |
Database name of the slow operation. |
| database_type ( tag) |
Database type. The value is MongoDB. |
| mongod_host ( tag) |
MongoDB server host. |
| normalized_query_hash ( tag) |
Hash of the canonical obfuscated command used to group equivalent slow operations. |
| operation ( tag) |
MongoDB operation type reported by system.profile. |
| plan_summary ( tag) |
Summary of the execution plan, such as COLLSCAN or IXSCAN. |
| query_hash ( tag) |
MongoDB queryHash or planCacheShapeHash. |
| query_shape_hash ( tag) |
MongoDB queryShapeHash when it is available. |
| query_signature ( tag) |
xxhash signature generated from database_name, collection, and query_shape_hash when queryShapeHash is available. |
| server ( tag) |
MongoDB server address. |
| user ( tag) |
MongoDB user that executed the operation. |
| client | Client address that executed the operation. Type: string | (string) Unit: N/A |
| cpu_nanos | CPU time consumed by the operation. Type: int | (gauge) Unit: time,ns |
| cursor_exhausted | Whether the operation exhausted its cursor. Type: bool | (bool) Unit: N/A |
| docs_deleted | Number of documents deleted. Type: int | (gauge) Unit: count |
| docs_examined | Number of documents examined. Type: int | (gauge) Unit: count |
| docs_inserted | Number of documents inserted. Type: int | (gauge) Unit: count |
| docs_matched | Number of documents matched. Type: int | (gauge) Unit: count |
| docs_modified | Number of documents modified. Type: int | (gauge) Unit: count |
| docs_returned | Number of documents returned. Type: int | (gauge) Unit: count |
| duration_ms | Total duration of the slow operation. Type: int | (gauge) Unit: time,ms |
| from_multi_planner | Whether the operation used the multi-planner. Type: bool | (bool) Unit: N/A |
| has_sort_stage | Whether the operation used a sort stage. Type: bool | (bool) Unit: N/A |
| keys_examined | Number of index keys examined. Type: int | (gauge) Unit: count |
| keys_inserted | Number of index keys inserted. Type: int | (gauge) Unit: count |
| message | Complete obfuscated MongoDB command. Type: string | (string) Unit: N/A |
| namespace | MongoDB namespace of the slow operation. Type: string | (string) Unit: N/A |
| num_yields | Number of times the operation yielded. Type: int | (gauge) Unit: count |
| plan_cache_key | MongoDB plan cache key. Type: string | (string) Unit: N/A |
| planning_time_micros | Time spent planning the operation. Type: int | (gauge) Unit: time,μs |
| query_framework | Query execution framework reported by MongoDB. Type: string | (string) Unit: N/A |
| query_truncated | Whether MongoDB reported the command as truncated. Type: string | (string) Unit: N/A |
| replanned | Whether MongoDB replanned the operation. Type: bool | (bool) Unit: N/A |
| response_length | Response size in bytes. Type: int | (gauge) Unit: digital,B |
| used_disk | Whether the operation used disk. Type: bool | (bool) Unit: N/A |
| working_millis | Time spent working on the operation. Type: int | (gauge) Unit: time,ms |
| write_conflicts | Number of write conflicts encountered. Type: int | (gauge) Unit: count |
Mongod Log Collection¶
Annotate the configuration file # enable_mongod_log = false and change false to true. Other configuration options for mongod log are in [inputs.mongodb.log], and the commented configuration is very default. If the path correspondence is correct, no configuration is needed. After starting DataKit, you will see a collection measurement named mongod_log.
Log raw data sample
{"t":{"$date":"2021-06-03T09:12:19.977+00:00"},"s":"I", "c":"STORAGE", "id":22430, "ctx":"WTCheckpointThread","msg":"WiredTiger message","attr":{"message":"[1622711539:977142][1:0x7f1b9f159700], WT_SESSION.checkpoint: [WT_VERB_CHECKPOINT_PROGRESS] saving checkpoint snapshot min: 653, snapshot max: 653 snapshot count: 0, oldest timestamp: (0, 0) , meta checkpoint timestamp: (0, 0)"}}
Log cut field
| Field Name | Field Value | Description |
|---|---|---|
| message | Log raw data | |
| component | STORAGE | The full component string of the log message |
| context | WTCheckpointThread | The name of the thread issuing the log statement |
| msg | WiredTiger message | The raw log output message as passed from the server or driver |
| status | I | The short severity code of the log message |
| time | 2021-06-03T09:12:19.977+00:00 | Timestamp |