重要
The feature described on this page is not currently supported on Atlas Infinite clusters during public preview. For the features supported in public preview, see Public Preview Availability.
Each mongod and mongos instance keeps an account of its activity in its own log file. Atlas retains the last 30 days of log messages and system event audit messages. The Performance Advisor retains at most 7 days of logs. If you terminate a cluster, the logs that cluster generated persist, and you can download these logs at any point until the end of their retention periods if you have the Project Cluster Log Viewer access.
注意
注意
免费集群(以前称为 M0)和 Flex集群不提供可下载的日志。
To learn about recommendations for auditing and logging, including the events that we recommend auditing, see Guidance for Atlas Auditing and Logging in the Atlas Architecture Center.
必需的访问权限
要下载数据库访问权限日志,您必须至少拥有Project Database Access Admin 访问权限。
要下载日志,您必须对项目拥有 Project Data Access Read Only 或更高访问权限。拥有 Organization Owner 访问权限的用户须将自身作为 Project Owner 添加到此项目中。
查看和下载云部署日志
如需使用 Atlas CLI 下载包含所选主机名日志的压缩文件, 请运行以下命令:
atlas logs download <hostname> <mongodb.gz|mongos.gz|mongosqld.gz|mongodb-audit-log.gz|mongos-audit-log.gz> [options]
要了解有关命令语法和参数的更多信息,请参阅 Atlas CLI 文档中的 atlas logs download。
要使用 Atlas UI 下载给定集群中单个进程的日志,请执行以下操作:
AtlasGoClusters在Atlas中,Go项目的 页面。
如果尚未显示,请从导航栏上的 Organizations 菜单中选择包含所需项目的组织。
如果尚未显示,请从导航栏的Projects菜单中选择所需的项目。
在侧边栏中,单击 Database 标题下的 Clusters。
会显示集群页面。
编辑这些字段。
在“Download Logs”对话框中,编辑以下字段:
字段 | 内容 |
|---|---|
选择流程 | 选择要记录日志的进程。对于唯一可用日志类型为 有效选项包括: |
选择服务器 | 选择集群中要检索其日志的服务器。 |
时间段 | 选择要返回的日志活动的时间范围。如果选择“Custom Time”,请指定要返回的日志活动的开始和结束时间。开始时间必须至少在 30 天之前。 重要提示:为确保您的日志数据在所需的时间范围内返回,请在您的 Atlas 项目设置中设置时区。 |
有关读取 MongoDB 日志的信息,请参阅 MongoDB 手册中的日志消息文档。
使用 Atlas CLI 查看本地部署日志
要使用 Atlas CLI 查看部署日志,请运行以下命令:
atlas deployments logs [options]
如需进一步了解命令语法和参数,请参阅 Atlas CLI 文档中的 Atlas 部署日志。
数据库访问日志
注意
此功能适用于 M10 集群或更高版本。要进一步学习;了解哪些功能可用于免费集群,请参阅Atlas免费集群限制;有关 Flex 集群,请参阅Atlas Flex 限制。
您可以查看针对集群进行的身份验证尝试。成功和不成功的尝试都会被记录下来,包括尝试的时间戳以及对应用户。