---
title: Running the MongoDB Profiler
slug: user-guide-10x/running-the-mongodb-profiler
docTags: 
createdAt: 2025-12-13T10:39:26.676Z
---

Customers experiencing Swimlane Platform performance problems may be asked to assist in gathering diagnostic data, including the identification of long-running, poor-performing MongoDB queries.

This is done in MongoDB admin clients (such as Robo 3T and the mongo shell) as follows:

1. **Connect to the Swimlane database.**

:::BlockQuote{indent="1"}
*use Swimlane*
:::

2. **Discard the contents of previous profiling sessions.**

:::BlockQuote{indent="1"}
*db.system.profile.drop()*
:::

3. **Enable the profiler making a thoughtful choice about what query duration to capture.**
   The following will cause only queries running longer than 2 seconds (2000 ms) to be captured.

:::BlockQuote{indent="1"}
*db.setProfilingLevel(2, \{ slowms: 2000 })*
:::

4. ***Demonstrate the problem symptom.***
   Perform whatever operations are necessary within Swimlane to re-create the poor performance scenario. While poor performance is ongoing use

:::BlockQuote{indent="1"}
*db.system.profile.count()*
:::

:::Paragraph{indent="1"}
to see how quickly the collection *db.system.profile* is filling up. It has a 1 MB maximum size, and so it will accommodate several hundred captured queries. See below for instructions to increase this maximum size if needed.
:::

5. **Stop the profiler (leave it running for 30 seconds after re-creating the poor performance).**

:::BlockQuote{indent="1"}
*db.setProfilingLevel(0)*
:::

6. **Export the entire system.profile collection.&#x20;**&#x54;hen, attach it to your Support Portal ticket.

   Step 1: Set the namespace

:::BlockQuote{indent="1"}
$ export NS=\<ENTER NAMESPACE HERE>
:::

:::Paragraph{indent="1"}
Step 2: Identify which mongo pod is primary
:::

:::BlockQuote{listRestartPolite="3" indent="1"}
$ kubectl exec swimlane-sw-mongo-0 -n $NS -- mongo -u Admin -p  --authenticationDatabase admin --ssl --sslAllowInvalidHostnames --sslAllowInvalidCertificates admin --eval="rs.isMaster();" | grep primary
:::

:::Paragraph{listRestartPolite="3" indent="1"}
Step 3: Export the system.profile collection. In the example below, swimlane-sw-mongo-0 is PRIMARY.
:::

:::BlockQuote{listRestartPolite="3" indent="1"}
$ kubectl exec swimlane-sw-mongo-0 -n $NS -- /bin/bash -c "mongoexport -u Admin -p --authenticationDatabase admin --ssl --sslAllowInvalidCertificates --db Swimlane --collection system.profile" > /tmp/system-profile-data-mongo.json
:::

7. Submit /tmp/system-profile-data-mongo.json to Support
8. It may be necessary to repeat the above procedure several times to ensure that the poorest performing queries are captured for analysis. Keep these tips in mind:

- As directed by Swimlane Support, it may be necessary to alter the *slowms* parameter in step 3.
  - Reduce *slowms* if no queries are being captured.
  - Increase *slowms* if too many queries are being captured.
    - Alternately, increase the maximum size limit of *db.system.profile&#x20;*&#x62;y issuing this command, *db.createCollection( "system.profile", \{ capped: true, size:4000000 } )*, after step 2 and before step 3.
    - For more information, see https\://docs.mongodb.com/manual/tutorial/manage-the-database-profiler/ section *Change Size of system.profile Collection on the Primary.*


