MongoDB records MongoDB在部署日志中记录$queryStats operations in the deployment logs. $queryStats操作。By default, MongoDB only logs the invocation of 默认情况下,MongoDB只记录$queryStats operations, not the operation's output. $queryStats操作的调用,而不是操作的输出。For 对于包含$queryStats operations that include the transformIdentifiers option, you can specify whether the transformed output is included in the log entry.transformIdentifiers选项的$queryStats操作,您可以指定转换后的输出是否包含在日志条目中。
Including 在日志中包含$queryStats output in the logs provides more information on specific $queryStats operations, but can negatively impact cluster performance as log updates take more time and resources.$queryStats输出可以提供有关特定$queryStat操作的更多信息,但会对集群性能产生负面影响,因为日志更新需要更多的时间和资源。
About this Task关于此任务
When MongoDB logs 当MongoDB记录$queryStats output, the results are redacted and anonymized. $queryStats output does not contain literals or field values.$queryStats输出时,结果会被编辑和匿名化。$queryStats输出不包含文字或字段值。
For an example of transformed 有关转换后的$queryStats output, see Transformed Example.$queryStats输出的示例,请参阅转换示例。
Steps步骤
In the MongoDB Atlas UI, go to the Clusters page for your project.在MongoDB Atlas UI中,转到项目的“集群”页面。
Warning
Navigation Improvements In Progress导航改进正在进行中
We're currently rolling out a new and improved navigation experience. If the following steps don't match your view in the Atlas UI, see the preview Atlas documentation.我们目前正在推出一种新的、改进的导航体验。如果以下步骤与Atlas UI中的视图不匹配,请参阅Atlas预览文档。
If it's not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.如果尚未显示,请从导航栏的“组织”菜单中选择包含所需项目的组织。If it's not already displayed, select your project from the Projects menu in the navigation bar.如果尚未显示,请从导航栏中的“项目”菜单中选择您的项目。If it's not already displayed, click Clusters in the sidebar.如果尚未显示,请单击侧栏中的“集群”。
Examples示例
The following examples show the differences in log messages when 以下示例显示了包含$queryStats output is included.$queryStats输出时日志消息的差异。
Note
The example log entries are reformatted for readability.为了可读性,对示例日志条目进行了重新格式化。
$queryStats Output Omitted (Default Behavior)省略输出(默认行为)
{
"t":{"$date":"2023-11-27T20:58:59.212+00:00"},"s":"D1", "c":"QRYSTATS",
"id":7808300, "ctx":"conn31","msg":"Logging invocation
$queryStats","attr":{"commandSpec":{"transformIdentifiers":{"algorithm":"hmac-sha-256","hmacKey":"###"}}
}$queryStats Output Included产出包括
{
"t":{"$date":"2023-11-27T20:58:59.212+00:00"},"s":"D1", "c":"QRYSTATS",
"id":7808300, "ctx":"conn31","msg":"Logging invocation
$queryStats","attr":{"commandSpec":{"transformIdentifiers":{"algorithm":"hmac-sha-256","hmacKey":"###"}}
}
{
"t":{"$date":"2023-11-27T20:58:59.212+00:00"},"s":"D3", "c":"QRYSTATS",
"id":7808301, "ctx":"conn31","msg":"Logging all outputs of
$queryStats","attr":{"thisOutput":"{key: {queryShape: {cmdNs: {db:
\"hYt+nW/sr1/Zc3YR8nlGWFoesJdvywkw+cR9rMGzXU4=\", coll:
\"TRx6R3rvstYgX96gNmeOi5E3QVsOqzRbv7A9j3q7OvM=\"}, command: \"find\",
filter: {Wb/Uu22DzKZ/Os+ZvLgPKFKGZPV4cIMZ3Ybv1HfYih4=: {$lt:
\"?date\"}}, projection: {r5zQZllsGoqQuQp4Jm0eH2M6RrMqH84KHowcFaiverg=:
true}, sort: {r5zQZllsGoqQuQp4Jm0eH2M6RrMqH84KHowcFaiverg=: 1}},
readConcern: {}, collectionType: \"nonExistent\"}, metrics:
{lastExecutionMicros: 208, execCount: 21, totalExecMicros: {sum: 6079,
max: 1875, min: 198, sumOfSquares: 4401645}, firstResponseExecMicros:
{sum: 6079, max: 1875, min: 198, sumOfSquares: 4401645}, docsReturned:
{sum: 0, max: 0, min: 0, sumOfSquares: 0}, firstSeenTimestamp:
2023-11-27T19:15:51.317Z, latestSeenTimestamp:
2023-11-27T20:55:51.309Z}, asOf: 2023-11-27T20:58:59.212Z}"}
}
{
"t":{"$date":"2023-11-27T20:58:59.213+00:00"},"s":"D3", "c":"QRYSTATS",
"id":7808301, "ctx":"conn31","msg":"Logging all outputs of
$queryStats","attr":{"thisOutput":"{key: {queryShape: {cmdNs: {db:
\"j+Caz+gxt7vl++gmeCAWrvyhDL17WaNrSIDi6Au7VI0=\", coll:
\"f/LCkK/kVEbt4fk2NNbyDPhxas+kzCLLcVbjeNBbhyg=\"}, let:
{pUZAyEEImSXcu8deG05tfIf6F/H92YsFnkZXIeRQtgc=: \"?number\"}, command:
\"aggregate\", pipeline: [{$group: {_id: \"?number\",
5E6FSc5VxCvIZK0jrqkY3k3aX51jSc73hQwO/8kH0lo=: {$sum: \"?number\"}}}],
explain: true, allowDiskUse: false}, client: {driver: {name:
\"nodejs|mongosh\", version: \"5.1.0\"}, os: {type: \"Darwin\", name:
\"darwin\", architecture: \"arm64\", version: \"22.6.0\"}, platform:
\"Node.js v16.19.1, LE (unified)\", version: \"5.1.0|1.8.0\",
application: {name: \"mongosh 1.8.0\"}}, collectionType: \"collection\",
cursor: {batchSize: \"?number\"}}, metrics: {lastExecutionMicros: 0,
execCount: 1, totalExecMicros: {sum: 0, max: 0, min: 0, sumOfSquares:
0}, firstResponseExecMicros: {sum: 0, max: 0, min: 0, sumOfSquares: 0},
docsReturned: {sum: 0, max: 0, min: 0, sumOfSquares: 0},
firstSeenTimestamp: 2023-11-27T19:31:36.463Z, latestSeenTimestamp:
2023-11-27T19:31:36.463Z}, asOf: 2023-11-27T20:58:59.213Z}"}
}
// Additional $queryStats output...