获取模式建议
通过分析 20 最活跃的集合,为集群提供模式改进建议。
基本 URL: https://cloud.mongodb.com/api/public/v 1.0
Resource
GET /groups/{PROJECT-ID}/performanceAdvisor/schemaAdvice
请求路径参数
Parameter | 类型 | 说明 |
---|---|---|
PROJECT-ID | 字符串 | (必需。)拥有此MongoDB 部署的项目的唯一标识符。群组和项目是同义词。您的群组 ID(group ID)与您的项目ID相同。 |
请求查询参数
需要 clusterId
或 hostId
。
Parameter | 类型 | 说明 |
---|---|---|
pretty | 布尔 | 指示响应正文是否应采用 美观打印 格式。 |
envelope | 布尔 | 指示是否要将响应封装在信封中。 |
clusterId | 字符串 | 副本集或分片集群的唯一标识符。如果您需要使用 |
hostId | 字符串 | 您想要模式建议的独立运行实例的唯一标识符。如果 |
请求正文参数
此端点不使用 HTTP 请求正文参数。
响应
名称 | 类型 | 说明 |
---|---|---|
| 对象列表 | 包含针对每个命名空间的模式改进的建议操作。 |
| 对象 | 包含Performance Advisor模式改进建议的命名空间。 |
| 阵列 | 命名空间列表以及有关这些命名空间触发建议的原因的信息。 |
| 字符串 | 受影响集合的命名空间。这是针对 |
| 对象 | 有关激活建议的触发的详细信息。 |
| 字符串 | 触发类型的描述。 |
| 字符串 | 触发类型。 选项包括:
|
| 字符串 | 指定推荐的描述。 |
| 字符串 | 推荐类型。选项包括:
|
请求示例
curl --user '{PUBLIC-KEY}:{PRIVATE-KEY}' --digest \ --header 'Accept: application/json' \ --include \ --request GET 'https://cloud.mongodb.com/api/public/v1.0/groups/{PROJECT-ID}/performanceAdvisor/schemaAdvice?clusterId={clusterId}&pretty=true'
响应示例
响应标头
401 Unauthorized Content-Type: application/json;charset=ISO-8859-1 Date: {dateInUnixFormat} WWW-Authenticate: Digest realm="MMS Public API", domain="", nonce="{nonce}", algorithm=MD5, op="auth", stale=false Content-Length: {requestLengthInBytes} Connection: keep-alive
200 OK Vary: Accept-Encoding Content-Type: application/json Strict-Transport-Security: max-age=300 Date: {dateInUnixFormat} Connection: keep-alive Content-Length: {requestLengthInBytes} X-MongoDB-Service-Version: gitHash={gitHash}; versionString={ApplicationVersion}
响应体
{ "content" : { "recommendations" : [ { "affectedNamespaces" : [ { "namespace" : "someDb.someCollection", "triggers" : [ { "description" : "Documents larger than 2 MB found in the collection(s) scanned", "triggerType" : "DOC_SIZE_TOO_LARGE" } ] }, { "namespace" : "someDb1.someCollection1", "triggers" : [ { "description" : "Documents larger than 2 MB found in the collection(s) scanned", "triggerType" : "DOC_SIZE_TOO_LARGE" } ] } ], "description" : "Reduce the size of documents", "recommendation" : "REDUCE_DOCUMENT_SIZE" }, { "affectedNamespaces" : [ { "namespace" : "someDb2.someCollection2", "triggers" : [ { "description" : "More than 30 indexes detected in the collection(s) scanned", "triggerType" : "NUM_INDEXES" } ] }, { "namespace" : "someDb3.someCollection3", "triggers" : [ { "description" : "More than 30 indexes detected in the collection(s) scanned", "triggerType" : "NUM_INDEXES" } ] } ], "description" : "Remove unnecessary indexes", "recommendation" : "REMOVE_UNNECESSARY_INDEXES" }, { "affectedNamespaces" : [ { "namespace" : "someDb4.someCollection4", "triggers" : [ { "description" : "Arrays with over 10000 entries detected in the collection(s) scanned", "triggerType" : "DOCS_CONTAIN_UNBOUNDED_ARRAY" } ] } ], "description" : "Avoid using unbounded arrays in documents", "recommendation" : "AVOID_UNBOUNDED_ARRAY" } ] }, "status" : 200 }