Navigation

Get Slow Queries

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

Info With Circle IconCreated with Sketch.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.

Info With Circle IconCreated with Sketch.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 authenticates using HTTP Digest Authentication. Provide a programmatic API public key and corresponding private key as the username and password when constructing the HTTP request.

To learn how to configure API access for an Atlas project, see Configure Atlas API Access.

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

GET /groups/{GROUP-ID}/processes/{PROCESS-ID}/performanceAdvisor/slowQueryLogs
Path ElementDescription
GROUP-IDUnique identifier for the project.
PROCESS-IDThe 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.

All parameters are optional.

Path ElementTypeDescription
sincelongPoint in time from which to retrieve slow query logs, stated in milliseconds since epoch.
durationlongLength of time in milliseconds during which to find slow query logs among the managed namespaces in the cluster.
namespacesstring

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.

Beaker IconExample

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

Omit to return results for all namespaces.

nLogslongMaximum number of log lines to return. Defaults to 20000.
prettybooleanDisplay response in a prettyprint format. Defaults to false.
envelopebooleanSpecifies whether or not to wrap the response in an envelope. Defaults to false.
Info With Circle IconCreated with Sketch.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.

This endpoint does not use HTTP request body parameters.

NameTypeDescription
slowQueriesarray of documentsA list of documents with information about slow queries as detected by the Performance Advisor.
slowQueries[n].linestringThe raw log line pertaining to the slow query.
slowQueries[n].namespacestringThe namespace in which the slow query ran.
curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --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"
{
"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"
} ]
}
Give Feedback