日志字段详情

更新时间:
复制为 MD 格式

MongoDB日志包括审计日志、慢日志和运行日志,本文介绍各类日志的字段详情。

审计日志

审计日志存储在名为mongo_audit_log_standardLogStore中,具体字段说明如下表所示。

说明

审计日志和慢日志的日志字段相同,通过audit_type字段区分。慢日志中的audit_type字段值固定为slowop,如果为其他值,则为审计日志。

字段

说明

__topic__

日志主题,固定为mongo_audit_log

audit_type

日志类型,例如Command。audit_type 为 'command' 时,包含的具体命令如下表所示。

coll

数据集合

db

数据库名称

docs_examined

文档扫描行数

instanceid

MongoDB实例ID

keys_examined

索引扫描行数

latency

消耗时间

optype

操作类别

  • query:查询

  • find:查询

  • insert:插入

  • update:更新

  • delete:删除

  • remove:删除

  • getMore:读取

  • command:协议命令

return_num

返回记录数

thread_id

线程ID

time

时间戳

user

登录MongoDB数据库的用户名

user_ip

连接MongoDB客户端的IP地址

audit_type 为 'command' 时,包含的具体命令分类如下表所示。

命令分类

具体命令

查询和聚合命令

aggregate、count、distinct、mapReduce、explain、getMore、killCursors

索引操作命令

createIndexes、dropIndexes、listIndexes、reIndex

集合和数据库操作命令

create、drop、collMod、listCollections、listDatabases、dropDatabase、renameCollection、convertToCapped

服务器信息和诊断命令

serverStatus、buildInfo、ping、hello、isMaster、currentOp、killOp、collStats、dbStats、hostInfo、connectionStatus、top

维护和验证命令

validate、compact、getParameter、setParameter、setFeatureCompatibilityVersion

副本集管理命令

replSetGetStatus、replSetGetConfig、replSetReconfig、replSetStepDown、replSetFreeze、replSetInitiate

分片管理命令

enableSharding、shardCollection、addShard、removeShard、balancerStart、balancerStop、moveChunk、splitChunk、flushRouterConfig

用户管理命令

createUser、dropUser、updateUser

角色管理命令

createRole、dropRole、grantRolesToUser、revokeRolesFromUser、usersInfo、rolesInfo

会话管理命令

startSession、endSessions、killAllSessions、refreshSessions

事务命令

commitTransaction、abortTransaction、coordinateCommitTransaction

认证命令

authenticate、logout、saslStart、saslContinue

系统管理命令

fsync、logRotate、shutdown、profile

计划缓存命令

planCacheClear、planCacheSetFilter

其他命令

dataSize、dbHash

慢日志

慢日志存储在名为mongo_slow_run_logLogStore中,具体字段说明如下表所示。

字段

说明

__topic__

日志主题,固定为mongo_slow_log

audit_type

日志类型,固定为slowop

coll

数据集合

db

数据库名称

docs_examined

文档扫描行数

instanceid

MongoDB实例ID

keys_examined

索引扫描行数

latency

消耗时间

optype

操作类别

  • query:查询

  • find:查询

  • insert:插入

  • update:更新

  • delete:删除

  • remove:删除

  • getMore:读取

  • command:协议命令

return_num

返回记录数

thread_id

线程ID

time

时间戳,单位:秒

user

登录MongoDB数据库的用户名

user_ip

连接MongoDB客户端的IP地址

运行日志

运行日志存储在名为mongo_slow_run_logLogStore中,具体字段说明如下表所示。

字段

说明

__topic__

日志主题,固定为mongo_run_log

category

日志类别,例如NETWORK(网络链接日志)

connection

日志连接信息

content

日志内容

instanceid

MongoDB实例ID

ip

IP地址

level

日志级别

port

端口号

time

日志生成时间