返回查询统计摘要
返回给定集群的查询结构统计摘要列表。查询结构统计提供有关MongoDB查询的性能见解,帮助用户识别有问题的查询模式和潜在的优化。
路径参数
-
用于标识项目的唯一 24-十六进制数字字符串。 使用 /groups 端点检索身份验证的用户有权访问权限的所有项目。
注意:群组和项目是同义词。您的群组 ID 与项目 ID 相同。对于现有群组,群组/项目 ID 保持不变。资源和相应的端点使用“群组”一词。
格式应符合以下模式:
^([a-f0-9]{24})$
。 -
用于标识集群的人类可读标签。
格式应符合以下模式:
^[a-zA-Z0-9][a-zA-Z0-9-]*$
。
查询参数
-
检索检索查询结构统计信息的日期和时间。该参数以自UNIX 纪元以来经过的毫秒数表示其值。
- 如果未指定 until 参数,端点将返回包含 since 值和当前时间的数据。
- 如果您既不指定 since 也不指定 until 参数,该端点将返回过去 24 小时的数据。
最小值为
1199145600000
。 -
检索查询结构统计信息的结束日期和时间。该参数以自 UNIX 纪元以来经过的毫秒数表示其值。
- 如果指定 until 参数,则必须指定 since 参数。
- 如果您既不指定 since 也不指定 until 参数,该端点将返回过去 24 小时的数据。
最小值为
1199145600000
。 -
要从中检索查询结构统计信息的 ProcessId。processId 是为MongoDB进程提供服务的托管和端口的组合。托管必须是运行MongoDB进程(
mongod
或mongos
)的托管的主机名、FQDN、IPv4解决或 IPv6解决。该端口必须是MongoDB进程侦听请求的 IANA 端口。要包含多个 processId,请多次传递参数,并在每个 processId 之间用 & 符号 (&
) 分隔。不超过
10
个元素。每个的格式应符合以下模式:^([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-f]{1,4}\:){7}([0-9a-f]{1,4})|(([a-z0-9]+\.){1,10}[a-z]+)?(\:[0-9]{4,5})$
。 -
从中检索查询结构统计信息的命名空间。命名空间由一个数据库和一个集合资源组成,写作
.
:<database>.<collection>
。要包含多个命名空间,请多次传递该参数,并在每个命名空间之间用 & 符号 (&
) 分隔。省略此参数可返回所有命名空间的结果。不超过
10
个元素。 -
检索与指定MongoDB命令匹配的查询结构统计信息。要包含多个命令,请多次传递参数,并在每个命令之间用与号 (
&
) 分隔。当前支持的参数包括 find、distinct 和aggregate。省略此参数可返回所有支持命令的结果。不超过
3
个元素。值为find
、distinct
或aggregate
。 -
要返回的查询统计摘要的最大数量。
最小值为
1
,最大值为100
。默认值为100
。 -
查询要检索的形状统计数据系列。系列表示有关查询执行的特定指标。要包含多个系列,请多次传递该参数,并在每个系列之间用与号 (
&
) 分隔。省略此参数可返回所有可用系列的结果。不超过
14
个元素。值为TOTAL_EXECUTION_TIME
、AVG_EXECUTION_TIME
、EXECUTION_COUNT
、KEYS_EXAMINED
、DOCS_EXAMINED
、DOCS_RETURNED
、TOTAL_TIME_TO_RESPONSE
、BYTES_READ
、KEYS_EXAMINED_RETURNED
、DOCS_EXAMINED_RETURNED
、LAST_EXECUTION_TIME
、P50_EXECUTION_TIME
、P90_EXECUTION_TIME
或P99_EXECUTION_TIME
。 -
所需查询结构的 SHA256 哈希列表,由 $queryStats 和 $explain 等MongoDB命令或慢查询日志输出。要包含多个系列,请多次传递该参数,并在每个系列之间用与号 (
&
) 分隔。省略此参数可返回所有可用系列的结果。不超过
10
个元素。每个的格式应符合以下模式:^([a-fA-F0-9]{64})$
。 -
指示应用程序是否将响应包装在
envelope
JSON 对象中的标志。某些 API 客户端无法访问 HTTP 响应标头或状态代码。要修复此问题,请在查询中设置 Envelope=true。返回结果列表的端点将结果对象用作 envelope。应用程序将状态参数添加到响应正文中。默认值为
false
。 -
指示响应正文是否应采用 prettyprint 格式的标记。
默认值为
false
。Prettyprint
atlas api queryShapeInsights listGroupClusterQueryShapeInsightSummaries --help
import (
"os"
"context"
"log"
sdk "go.mongodb.org/atlas-sdk/v20250312001/admin"
)
func main() {
ctx := context.Background()
clientID := os.Getenv("MONGODB_ATLAS_CLIENT_ID")
clientSecret := os.Getenv("MONGODB_ATLAS_CLIENT_SECRET")
// See https://dochub.mongodb.org/core/atlas-go-sdk-oauth
client, err := sdk.NewClient(sdk.UseOAuthAuth(clientID, clientSecret))
if err != nil {
log.Fatalf("Error: %v", err)
}
params = &sdk.ListGroupClusterQueryShapeInsightSummariesApiParams{}
sdkResp, httpResp, err := client.QueryShapeInsightsApi.
ListGroupClusterQueryShapeInsightSummariesWithParams(ctx, params).
Execute()
}
curl --include --header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Accept: application/vnd.atlas.2025-03-12+json" \
-X GET "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/queryShapeInsights/summaries?pretty=true"
curl --user "${PUBLIC_KEY}:${PRIVATE_KEY}" \
--digest --include \
--header "Accept: application/vnd.atlas.2025-03-12+json" \
-X GET "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/queryShapeInsights/summaries?pretty=true"
{
"summaries": [
{
"avgWorkingMillis": 42.0,
"bytesRead": 42.0,
"command": "find",
"docsExamined": 42.0,
"docsExaminedRatio": 42.0,
"docsReturned": 42.0,
"execCount": 42.0,
"keysExamined": 42.0,
"keysExaminedRatio": 42.0,
"lastExecMicros": 42.0,
"namespace": "string",
"p50ExecMicros": 42.0,
"p90ExecMicros": 42.0,
"p99ExecMicros": 42.0,
"queryShape": "string",
"queryShapeHash": "string",
"totalTimeToResponseMicros": 42.0,
"totalWorkingMillis": 42.0
}
]
}
{
"error": 400,
"detail": "(This is just an example, the exception may not be related to this endpoint) No provider AWS exists.",
"reason": "Bad Request",
"errorCode": "VALIDATION_ERROR"
}
{
"error": 401,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Unauthorized",
"errorCode": "NOT_ORG_GROUP_CREATOR"
}
{
"error": 403,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Forbidden",
"errorCode": "CANNOT_CHANGE_GROUP_NAME"
}
{
"error": 404,
"detail": "(This is just an example, the exception may not be related to this endpoint) Cannot find resource AWS",
"reason": "Not Found",
"errorCode": "RESOURCE_NOT_FOUND"
}
{
"error": 429,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Too Many Requests",
"errorCode": "RATE_LIMITED"
}
{
"error": 500,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Internal Server Error",
"errorCode": "UNEXPECTED_ERROR"
}