Skip to main content
Version: 25.03

DB Viewer - Mongotop

Endpoint​

/o/db/mongotop

Overview​

Returns a single mongotop sample for the Countly database: how much time MongoDB spent reading and writing each collection.

The server runs the mongotop command-line tool once, takes its first output, and returns it as an array of rows. Each row is an array of strings.

Authentication​

Pass api_key or auth_token as a query parameter, or send countly-token as a header. See Authentication.

Permissions​

Requires a global administrator.

Request Parameters​

ParameterTypeRequiredDescription
api_keyStringConditionalRequired if auth_token is not provided.
auth_tokenStringConditionalRequired if api_key is not provided.

Examples​

Read one mongotop sample​

/o/db/mongotop?api_key=YOUR_API_KEY

Response​

Success Response​

The response is a JSON array of rows. Every row is an array of strings.

[
["column 1", "column 2", "..."],
["value 1", "value 2", "..."]
]

Error Responses​

  • 400
{
"result": "Missing parameter \"api_key\" or \"auth_token\""
}
  • 400
{
"result": "Token not valid"
}
  • 401
{
"result": "User does not exist"
}
  • 401
{
"result": "User does not have right"
}

Behavior​

  • Only global administrators can call this endpoint.
  • Requires the mongotop tool to be installed on the Countly server.
  • Connects to the countly database using the server's configured database connection.
  • Returns after the first output of the tool; the tool is then stopped.
Implementation details

Database Collections

This endpoint does not read Countly collections directly. It runs the mongotop tool against the countly database.