Navigation

Get Existing Indexes for a Host

Note

Groups and projects are synonymous terms. Your {GROUP-ID} is the same as your project ID. For existing groups, your group/project ID remains the same. The resource and corresponding endpoints use the term groups.

Retrieve existing indexes for the specified host. For more information, see Performance Advisor. Keys in indexes with multiple keys appear in the same order that they appear in the index. For more information about slow queries, see Performance Advisor.

The Atlas API uses HTTP Digest Authentication. Provide your Atlas username and API key as the username and password when constructing the HTTP request.

For complete documentation on configuring API access for an Atlas project, see Configure Atlas API Access.

Base URL: https://cloud.mongodb.com/api/atlas/v1.0

Resource

GET /groups/{GROUP-ID}/processes/{PROCESS-ID}/performnceAdvisor/existingIndexes

Request Path Parameters

Path Element Description
GROUP-ID The unique identifier for the project where the the MongoDB host resides.
PROCESS-ID The unique identifier for the host of a MongoDB process in the following format: {hostname}:{port}. For information about retrieving process ids, see Get All MongoDB Processes in a Group.

Request Query Parameters

Field Required/Optional Description
namespaces Optional

A namespace for a collection for which you want to retrieve existing indexes on the specified host. To specify multiple namespaces, pass the parameter multiple times using an ampersand (&) as a delimiter, once for each namespace.

Example

?namespaces=data.stocks&namespaces=data.zips&pretty=true

If you do not specify this parameter, the endpoint return all namespaces for the corresponding collection on the specified host.

Request Body Parameters

This endpoint does not use HTTP request body parameters.

Response Elements

Field Type Description
collectedIndexes array Each array element represents one index.
collectedIndexes[i].index array

Each array element is a document that specifies a key in the index and its sort order, ascending or descending.

  • A value of 1 indicates an ascending sort order.
  • A value of -1 indicates a descending sort order.

Keys in indexes with multiple keys appear in the same order that they appear in the index.

collectedIndex[i].namespace string The namespace corresponding to the collection to which the index belongs. Namespaces appear in the following format: {database}.{collection}.

Example Request

curl --digest -i -u "{username}:{apiKey}" \
  "https://cloud.mongodb.com/api/atlas/v1.0/groups/6c381af480eef519ea5cdeb1/processes/cluste0-shard-00-00-mnswc.mongodb-dev.net:27017/performanceAdvisor/existingIndexes?pretty=true"

Example Response

{
  "collectedIndexes" : [ {
    "index" : [ {
      "_id" : "1"
    } ],
    "namespace" : "admin.system.users"
  }, {
    "index" : [ {
      "user" : "1"
    }, {
      "db" : "1"
    } ],
    "namespace" : "admin.system.users"
  }, {
    "index" : [ {
      "_id" : "1"
    } ],
    "namespace" : "config.cache.collections"
  }, {
    "index" : [ {
      "_id" : "1"
  } ],
    "namespace" : "data.stocks"
  }, {
    "index" : [ {
      "_id" : "1"
  } ],
    "namespace" : "data.zips"
  } ]
}