Navigation

Get Slow Queries

Return log lines for slow queries as determined by the Performance Advisor.

Note

Users without one of the following roles cannot successfully call the endpoint:

The other Performance Advisor endpoints allow users without these roles to call the endpoints and receive redacted data.

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.

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}/performanceAdvisor/slowQueryLogs

Request Path Parameters

Path Element Description
GROUP-ID Unique identifier for the project.
PROCESS-ID The Atlas hostname and port, e.g. m10-shard-00-00-17jcm.mongodb.net:27017. To retrieve all processes in the project with a given GROUP-ID, use the /groups/{GROUP-ID}/processes endpoint.

Request Query Parameters

All parameters are optional.

Path Element Type Description
since long Point in time from which to retrieve slow query logs, stated in milliseconds since epoch.
duration long Length of time in milliseconds during which to find slow query logs among the managed namespaces in the cluster.
namespaces string

Namespaces from which to retrieve slow query logs. A namespace consists of the database and collection resource separated by a ., such as <database>.<collection>.

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

Omit to return results for all namespaces.

nLogs long Maximum number of log lines to return. Defaults to 20000.
pretty boolean Display response in a prettyprint format. Defaults to false.
envelope boolean Specifies whether or not to wrap the response in an envelope. Defaults to false.

Note

If since is indicated and duration is omitted, the response contains results from the since point up to the present time.

If duration is indicated and since is omitted, the response contains results from duration ms ago through the present time.

If both since and duration are omitted, the response contains results from the previous 24 hours up through the present time.

Request Body Parameters

This endpoint does not use HTTP request body parameters.

Response

Name Type Description
slowQueries array of documents A list of documents with information about slow queries as detected by the Performance Advisor.
slowQueries[n].line string The raw log line pertaining to the slow query.
slowQueries[n].namespace string The namespace in which the slow query ran.

Example Request

curl --user "{username:apiKey}" --digest -i \
  --header "Accept: application/json" \
  --header "Content-Type: application/json" \
  --request GET "https://cloud.mongodb.com/api/atlas/v1.0/groups/{GROUP-ID}/processes/{PROCESS-ID}/performanceAdvisor/slowQueryLogs?namespaces=myDb.users&pretty=true"

Example Response

{
  "slowQueries" : [ {
    "line" : "2018-08-16T22:53:43.447+0000 I COMMAND  [conn10614] command myDb.users appName: \"MongoDB Shell\" command: find { find: \"users\", filter: { emails: \"tocde@fijoow.to\" }, lsid: { id: UUID(\"832b4b0e-085a-480e-b470-16a0994dc7cb\") }, $clusterTime: { clusterTime: Timestamp(1534460016, 1)...",
   "namespace" : "myDb.users"
  }, {
    "line" : "2018-08-16T22:54:32.705+0000 I COMMAND  [conn10614] command myDb.users appName: \"MongoDB Shell\" command: find { find: \"users\", filter: { emails: \"la@sa.kp\" }, lsid: { id: UUID(\"832b4b0e-085a-480e-b470-16a0994dc7cb\") }, $clusterTime: { clusterTime: Timestamp(1534460056, 1), ...",
    "namespace" : "myDb.users"
  } ]
}