MongoDB
MongoDB 数据库,Collection, MongoDB 数据库集群运行状态数据采集。
配置¶
前置条件¶
-
已测试的版本:
- 6.0
- 5.0
- 4.0
- 3.0
- 2.8.0
-
开发使用 MongoDB 版本
4.4.5; - 编写配置文件在对应目录下然后启动 DataKit 即可完成配置;
- 使用 TLS 进行安全连接请在配置文件中配置
## TLS connection config下响应证书文件路径与配置; - 如果 MongoDB 启动了访问控制那么需要配置必须的用户权限用于建立授权连接:
# 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" }
]
})
更多权限说明可参见官方文档 Built-In Roles。
执行完上述命令后将创建的「用户名」和「密码」填入 DataKit 的配置文件 conf.d/db/mongodb.conf 中。
采集器配置¶
进入 DataKit 安装目录下的 conf.d/samples 目录,复制 mongodb.conf.sample 并命名为 mongodb.conf。示例如下:
[[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"
# ...
配置好后,重启 DataKit 即可。
目前可以通过 ConfigMap 方式注入采集器配置来开启采集器。
数据库监控¶
MongoDB 数据库监控(DBM)包含 Query Metrics、Activity 和 Slow Operations。dbm.enabled 是总开关,databases 是三类采集共用的数据库过滤配置;空列表表示采集除 admin 外的所有数据库。
[[inputs.mongodb]]
# ... MongoDB 连接配置
[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 和 Activity 在开启 DBM 后默认启用;Slow Operations 默认关闭,需要单独开启。三类采集均使用 MongoDB 配置中第一个成功初始化的 server。
Query Metrics¶
Query Metrics 通过 $queryStats 采集按查询形态聚合的执行次数、耗时和扫描量。
前置条件¶
- MongoDB 需要 8.0 及以上版本。
- 自建 MongoDB 需要将
internalQueryStatsRateLimit设置为正整数;默认值0不记录 Query Stats。例如:
也可以通过 setParameter 动态修改;-1 表示不限制记录速率。
配置¶
enabled:开启 DBM 后 Query Metrics 默认启用,可设置为false单独关闭。interval:采集周期,默认60s。limit:每个采集周期最多处理的 Query Stats 条目数,默认10000。query_text_max_bytes:query_texttag 保存的脱敏查询文本最大字节数,默认512,最大1024。截断时保证 UTF-8 字符完整,并将query_truncated标记为true。
首次采集用于建立增量基线,后续采集会上报:
mongodb_dbm_metric:累计值以及以delta_开头的周期增量。db_query:脱敏后的查询命令,同一query_signature每 24 小时最多上报一次。
Activity¶
Activity 通过 $currentOp 采集当前正在执行的操作。
enabled:开启 DBM 后 Activity 默认启用,可设置为false单独关闭 Activity。interval:采集周期,默认10s。
每个可见操作生成一条脱敏后的 mongodb_dbm_activity 日志;同时聚合生成 mongodb_dbm_operation 指标,其中 active_operation_count 表示活跃操作数,waiting_for_lock_count 表示等待锁的操作数。该指标不表示 MongoDB 的全部连接数。
Slow Operations¶
Slow Operations 从各数据库的 system.profile 集合增量采集已完成的慢操作。需要在要监控的数据库中启用 MongoDB Profiler,例如:
enabled:默认关闭,需要同时开启dbm.enabled后显式启用。interval:采集周期,默认10s。max_operations:每个采集周期最多上报的慢操作数,默认1000。
每条慢操作生成一条 mongodb_dbm_slow_query 日志。日志时间取自 system.profile.ts,完整脱敏命令保存在 message 字段中;operation、command_type 和 plan_summary 等标签可用于聚合慢操作数量和执行耗时。
TLS 配置 (self-signed)¶
使用 openssl 生成证书文件用于 MongoDB TLS 配置,用于开启服务端加密和客户端认证。
- 配置 TLS 证书
安装 openssl 运行以下命令:
- 配置 MongoDB 服务端加密
使用 openssl 生成证书级密钥文件,运行以下命令并按照命令提示符输入相应验证块信息:
sudo openssl req -x509 -newkey rsa:<bits> -days <days> -keyout <mongod.key.pem> -out <mongod.cert.pem> -nodes
bits: rsa 密钥位数,例如 2048days: expired 日期mongod.key.pem: 密钥文件mongod.cert.pem: CA 证书文件
运行上面的命令后生成 cert.pem 文件和 key.pem 文件,我们需要合并两个文件内的 block 运行以下命令:
合并后配置 /etc/mongod.config 文件中的 TLS 子项
使用配置文件启动 MongoDB 运行以下命令:
使用命令行启动 MongoDB 运行一下命令:
复制 mongod.cert.pem 为 mongo.cert.pem 到 MongoDB 客户端并启用 TLS:
- 配置 MongoDB 客户端认证
使用 openssl 生成证书级密钥文件,运行以下命令:
sudo openssl req -x509 -newkey rsa:<bits> -days <days> -keyout <mongod.key.pem> -out <mongod.cert.pem> -nodes
bits: rsa 密钥位数,例如 2048days: expired 日期mongo.key.pem: 密钥文件mongo.cert.pem: CA 证书文件
合并 mongod.cert.pem 和 mongod.key.pem 文件中的 block 运行以下命令:
复制 mongod.cert.pem 文件到 MongoDB 服务端然后配置 /etc/mongod.config 文件中的 TLS 项:
# Tls config
net:
tls:
mode: requireTLS
certificateKeyFile: </etc/ssl/mongod.pem>
CAFile: </etc/ssl/mongod.cert.pem>
启动 MongoDB 运行以下命令:
复制 mongod.cert.pem 为 mongo.cert.pem ,复制 mongod.pem 为 mongo.pem 到 MongoDB 客户端并启用 TLS:
mongo --tls --host <mongod_url> --tlsCAFile </etc/ssl/mongo.cert.pem> --tlsCertificateKeyFile </etc/ssl/mongo.pem>
注意:使用自签名证书时,
mongodb.conf配置中insecure_skip_verify必须是true
指标¶
以下所有数据采集,默认会追加全局选举 tag,也可以在配置中通过 [inputs.mongodb.tags] 指定其它标签:
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 |
对象¶
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 指标字段结构¶
message 字段存放 MongoDB 启动/配置相关设置,数据来自 getCmdLineOpts admin 命令返回结果中的 parsed 部分。该字段不会包含命令行 argv、连接数或数据库统计信息。实际包含的 key 取决于 MongoDB 启动参数和配置文件。基本结构如下:
{
"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 |
日志¶
以下 DBM Activity 指标集以日志形式采集:
mongodb_dbm_activity¶
通过 $currentOp 快照采集的 MongoDB 当前活动操作。
| 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¶
从各数据库 system.profile 集合采集的 MongoDB 已完成慢操作。
| 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 日志采集¶
去注释配置文件中 # enable_mongod_log = false 然后将 false 改为 true,其他关于 mongod log 配置选项在 [inputs.mongodb.log] 中,注释掉的配置极为默认配置,如果路径对应正确将无需任何配置启动 DataKit 后将会看到指标名为 mongod_log 的采集指标集。
日志原始数据 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)"}}
日志切割字段
| 字段名 | 字段值 | 说明 |
|---|---|---|
| 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 |