Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Managed Service for MongoDB
  • Getting started
    • All guides
      • Viewing cluster logs
      • Performance diagnostics
      • Performance analysis tools
      • Monitoring the state of clusters and hosts
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Built-in diagnostic utilities
  • Profiler
  • Currently running queries
  • Logs
  1. Step-by-step guides
  2. Logs and monitoring
  3. Performance analysis tools

Performance analysis tools

Written by
Yandex Cloud
Updated at May 5, 2025
  • Built-in diagnostic utilities
    • Profiler
    • Currently running queries
  • Logs

Built-in diagnostic utilitiesBuilt-in diagnostic utilities

MongoDB offers utilities to help you get performance data:

  • mongostat: Collects statistics on CPU and memory usage with MongoDB processes.
  • mongotop: Collects data read/write statistics for each collection.

When calling these utilities, use the connection string with the username and password of the user with the mdbMonitor role, for example:

mongostat 5 --uri="mongodb://{<name_of_user_with_mdbMonitor_role>}:{<password>}@{<host>}:27018/?authSource=admin"
mongotop 5 --uri="mongodb://{<name_of_user_with_mdbMonitor_role>}:{<password>}@{<host>}:27018/?authSource=admin"

Here, both utilities provide a set of performance data with a polling interval of 5 seconds.

For more information about the monostat and mongotop utilities, see the MongoDB documentation.

ProfilerProfiler

MongoDB has a built-in profiler. It collects query data and then uses it to determine a query optimization strategy. The profiler runs based on the MongoDB settings that you can set when creating a cluster or updating the DBMS settings:

  • operationProfiling.mode;
  • operationProfiling.slowOpThreshold.

Warning

The use of the all value for operationProfiling.mode and a value close to 0 for operationProfiling.slowOpThreshold will significantly degrade cluster performance.

To view the data collected by the profiler, use the system.profile collection in each database. Profiler collections can be read by a user with the mdbMonitor role. By default, the data is duplicated in the logs.

For more information about configuring the profiler and how to interpret its results, see the MongoDB documentation.

Currently running queriesCurrently running queries

To view queries not pertaining to the current user, run the db.currentOp() query as a user with the mdbMonitor role:

db.currentOp()

To view the current user's queries, run the db.currentOp() query with the true value to configure ownOps:

db.currentOp({ "$ownOps": true })

LogsLogs

You can find the most detailed information about MongoDB performance in the logs.

Management console
CLI
REST API
gRPC API
  1. Go to the folder page and select Managed Service for MongoDB.
  2. Click the name of the cluster you need and select the Logs tab.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To view the Managed Service for MongoDB logs:

  1. See the description of the CLI command to view the logs:

    yc managed-mongodb cluster list-logs --help
    
  2. To get all the cluster logs, run the command:

    yc managed-mongodb cluster list-logs --id <cluster_ID>
    

    You can get the cluster ID with the list of clusters in the folder.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Use the Cluster.ListLogs method and send the following request, e.g., via cURL:

    curl \
        --request GET \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>:logs' \
        --url-query serviceType=<service_type> \
        --url-query columnFilter=<column_list> \
        --url-query fromTime=<time_range_left_boundary> \
        --url-query toTime=<time_range_right_boundary>
    

    Where:

    • serviceType: Type of the service to get logs for:

      • MONGOD: MongoDB operations log.
      • AUDIT: Audit log.
    • columnFilter: List of data columns:

      • hostname: Host name.
      • component: Type of component to log, Example: HTTP-Session.
      • message: Message output by the component.
      • query_id: Request ID.
      • severity: Logging level, e.g., Debug.
      • thread: ID of the thread involved in query handling.

      You can specify only one column in the columnFilter parameter. If you want to filter logs by more than one column, provide a list of the columns in several parameters.

      • fromTime: Left boundary of a time range in RFC-3339 format, Example: 2006-01-02T15:04:05Z.
      • toTime: Right boundary of a time range, the format is the same as for fromTime.

    You can request the cluster ID with the list of clusters in the folder.

  3. View the server response to make sure the request was successful.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Clone the cloudapi repository:

    cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
    

    Below, we assume the repository contents are stored in the ~/cloudapi/ directory.

  3. Use the ClusterService.ListLogs call and send the following request, e.g., via gRPCurl:

    grpcurl \
      -format json \
      -import-path ~/cloudapi/ \
      -import-path ~/cloudapi/third_party/googleapis/ \
      -proto ~/cloudapi/yandex/cloud/mdb/mongodb/v1/cluster_service.proto \
      -rpc-header "Authorization: Bearer $IAM_TOKEN" \
      -d '{
            "cluster_id": "<cluster_ID>",
            "service_type": "<service_type>",
            "column_filter": [
              "<column_1>", "<column_2>", ..., "<column_N>"
            ],
            "from_time": "<time_range_left_boundary>",
            "to_time": "<time_range_right_boundary>"
          }' \
      mdb.api.cloud.yandex.net:443 \
      yandex.cloud.mdb.mongodb.v1.ClusterService.ListLogs
    

    Where:

    • service_type: Type of the service to get logs for:

      • MONGOD: MongoDB operations log.
      • AUDIT: Audit log.
    • column_filter: List of data columns:

      • hostname: Host name.
      • component: Type of component to log, Example: HTTP-Session.
      • message: Message output by the component.
      • query_id: Request ID.
      • severity: Logging level, e.g., Debug.
      • thread: ID of the thread involved in query handling.

      You can specify more than one column in the column_filter parameter if you want to filter logs by multiple columns.

      • from_time: Left boundary of a time range in RFC-3339 format, Example: 2006-01-02T15:04:05Z.
      • to_time: Right boundary of a time range, the format is the same as for from_time.

    You can request the cluster ID with the list of clusters in the folder.

  4. View the server response to make sure the request was successful.

Was the article helpful?

Previous
Performance diagnostics
Next
Monitoring the state of clusters and hosts
Yandex project
© 2025 Yandex.Cloud LLC