---
title: How to show the count of all NetWitness mongodb documents in all collections?
description: "Issue\nAn administrator would like to understand how large the MongoDB databases are and how much space they consume on the Admin-Server, ESA, or Endpo"
---

[Skip to content](https://mydev.netwitness.com/knowledge-base/how-to-show-the-count-of-all-netwitness-mongodb-documents-in-all-collections#main-content)

![NW Logo](https://mydev.netwitness.com/hs-fs/hubfs/Portal-Partner%20Program/AssetFiles/NW%20Logo%20(2).png?width=180&height=32&name=NW%20Logo%20(2).png)

- [Home](https://mydev.netwitness.com/home)
- Integrations
  
  Show submenu for Integrations

    - [Netwitness Platform Integrations](https://mydev.netwitness.com/netwitnessplatformintegrations)
    - [Third Party Integrations](https://mydev.netwitness.com/thirdpartyintegrations)
- [Knowledge Center](https://mydev.netwitness.com/knowledge-base)
- Community
  
  Show submenu for Community

    - [Blogs](https://mydev.netwitness.com/netwitness-security-llc-blog)
    - Discussions
- Customers
  
  Show submenu for Customers

    - [Manage Products and Licenses](https://mydev.netwitness.com/nwportal)
    - Downloads
- Partners
  
  Show submenu for Partners

    - [Partner Program](https://mydev.netwitness.com/partner)
    - [Partner Resources](https://mydev.netwitness.com/partnerresources)
    - [Submit a New Deal Registration](https://mydev.netwitness.com/dealregistration)
    - [Become a Partner](https://mydev.netwitness.com/becomeapartner)
    - [Update Your Partner Locator Profile](https://www.netwitness.com/partner-locator/?utm_source=pardotnewsletter&utm_medium=email&utm_campaign=partner_march)
    - [NetWitness LinkedIn Partner Hub](https://linkedin.com/showcase/netwitnesspartners/)
- Education
  
  Show submenu for Education

    - [Instructor Led Training Schedule](https://mydev.netwitness.com/instructorledtrainingschedule)
    - [NetWitness Training Catalog](https://mydev.netwitness.com/netwitnesstrainingcatalog)
    - [Security Awareness Training](https://mydev.netwitness.com/securityawarenesstraining)
    - [New Product Readiness](https://mydev.netwitness.com/newproductreadiness)
    - [On-Demand Virtual Labs](https://mydev.netwitness.com/ondemandvirtuallabs)
    - [Additional Training Information](https://mydev.netwitness.com/additionaltraininginformation)
    - [Frequently Asked Questions](https://mydev.netwitness.com/educationfaq)
    - [Contact NetWitness Education Team](https://mydev.netwitness.com/contact-netwitness-education-team)
- Support
  
  Show submenu for Support

    - [Contact Support](https://mydev.netwitness.com/contact-support)
    - [Create a New Case](https://mydev.netwitness.com/create-support-case)
    - [View My Cases](https://mydev.netwitness.com/viewmycase)
    - [Product Version Life Cycle](https://mydev.netwitness.com/product-version-life-cycle)
    - [Warranty & Replacement Parts](https://mydev.netwitness.com/warranty-and-replacement-parts)
    - [Community Support Forum](https://mydev.netwitness.com/community-support-forum)
    - [Technical Support Guide](https://mydev.netwitness.com/technical-support-guide)

Open main navigation

Close main navigation

- [Home](https://mydev.netwitness.com/home)
- Integrations
  
  Show submenu for Integrations

    - [Netwitness Platform Integrations](https://mydev.netwitness.com/netwitnessplatformintegrations)
    - [Third Party Integrations](https://mydev.netwitness.com/thirdpartyintegrations)
- [Knowledge Center](https://mydev.netwitness.com/knowledge-base)
- Community
  
  Show submenu for Community

    - [Blogs](https://mydev.netwitness.com/netwitness-security-llc-blog)
    - Discussions
- Customers
  
  Show submenu for Customers

    - [Manage Products and Licenses](https://mydev.netwitness.com/nwportal)
    - Downloads
- Partners
  
  Show submenu for Partners

    - [Partner Program](https://mydev.netwitness.com/partner)
    - [Partner Resources](https://mydev.netwitness.com/partnerresources)
    - [Submit a New Deal Registration](https://mydev.netwitness.com/dealregistration)
    - [Become a Partner](https://mydev.netwitness.com/becomeapartner)
    - [Update Your Partner Locator Profile](https://www.netwitness.com/partner-locator/?utm_source=pardotnewsletter&utm_medium=email&utm_campaign=partner_march)
    - [NetWitness LinkedIn Partner Hub](https://linkedin.com/showcase/netwitnesspartners/)
- Education
  
  Show submenu for Education

    - [Instructor Led Training Schedule](https://mydev.netwitness.com/instructorledtrainingschedule)
    - [NetWitness Training Catalog](https://mydev.netwitness.com/netwitnesstrainingcatalog)
    - [Security Awareness Training](https://mydev.netwitness.com/securityawarenesstraining)
    - [New Product Readiness](https://mydev.netwitness.com/newproductreadiness)
    - [On-Demand Virtual Labs](https://mydev.netwitness.com/ondemandvirtuallabs)
    - [Additional Training Information](https://mydev.netwitness.com/additionaltraininginformation)
    - [Frequently Asked Questions](https://mydev.netwitness.com/educationfaq)
    - [Contact NetWitness Education Team](https://mydev.netwitness.com/contact-netwitness-education-team)
- Support
  
  Show submenu for Support

    - [Contact Support](https://mydev.netwitness.com/contact-support)
    - [Create a New Case](https://mydev.netwitness.com/create-support-case)
    - [View My Cases](https://mydev.netwitness.com/viewmycase)
    - [Product Version Life Cycle](https://mydev.netwitness.com/product-version-life-cycle)
    - [Warranty & Replacement Parts](https://mydev.netwitness.com/warranty-and-replacement-parts)
    - [Community Support Forum](https://mydev.netwitness.com/community-support-forum)
    - [Technical Support Guide](https://mydev.netwitness.com/technical-support-guide)

 How can we help you?

- There are no suggestions because the search field is empty.

1. [NetWitness Knowledge Base](https://mydev.netwitness.com/knowledge-base?hsLang=en)
2. [Break Fix](https://mydev.netwitness.com/knowledge-base/break-fix?hsLang=en)

April 30, 2026

# How to show the count of all NetWitness mongodb documents in all collections?

#### Issue

An administrator would like to understand how large the MongoDB databases are and how much space they consume on the Admin-Server, ESA, or Endpoint-Server. 

#### Resolution

1. Login to NetWitness appliance that is running the mongod service.
2. Confirm that the mongod service is running.  
   systemctl status mongod
   
   For example:
   
   \[root@NW ~\]# **systemctl status mongod**  
   ● mongod.service - MongoDB Database Server  
    Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)  
    Drop-In: /etc/systemd/system/mongod.service.d  
    └─mongod-start-managed.conf  
    Active: active (running) since Mon 2021-06-07 03:32:30 UTC; 1 weeks 6 days ago  
    Docs: https://docs.mongodb.org/manual  
    Process: 1876 ExecStart=/usr/bin/numactl --interleave=all /usr/bin/mongod $OPTIONS run (code=exited, status=0/SUCCESS)  
    Process: 1873 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)  
    Process: 1868 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)  
    Process: 1861 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)  
    Main PID: 3192 (mongod)  
    CGroup: /system.slice/mongod.service  
    └─3192 /usr/bin/mongod -f /etc/mongod.conf run
   
   Jun 07 03:32:19 NW5ESAPRIM systemd\[1\]: Starting MongoDB Database Server...  
   Jun 07 03:32:27 NW5ESAPRIM numactl\[1876\]: about to fork child process, waiting until server is ready for connections.  
   Jun 07 03:32:27 NW5ESAPRIM numactl\[1876\]: forked process: 3192  
   Jun 07 03:32:30 NW5ESAPRIM numactl\[1876\]: child process started successfully, parent exiting  
   Jun 07 03:32:30 NW5ESAPRIM systemd\[1\]: Started MongoDB Database Server.
3. Run the following mongo query to show a count of the documents for each collection in all database.  
   Can copy all of the below lines down to and including the final EOF line and paste into a bash command line, then press enter.
   
   `mongo admin -u deploy_admin -p netwitness --quiet <<EOF show dbs db = db.getSiblingDB('admin'); var dbs = db.adminCommand('listDatabases'); dbs.databases.forEach(function(database){ print("Database: " + database.name); print("-----"); if (database.name == "config") { print("Skipped"); } else { db = db.getSiblingDB(database.name); db.getCollectionNames().forEach(function(collection) { print("Collection '" + collection + "' documents: " + db[collection].count()); }); }; print(""); }); exit EOF` 
   
     1. For this portion: mongo admin -u deploy\_admin -p ***netwitness*** --quiet \<  Substitute  ***netwitness*** with the correct deploy\_admin password.

For example:

\[root@NW ~\]# mongo admin -u deploy\_admin -p netwitness --quiet \<\<EOF  
\>  
\> show dbs  
\>  
\> db = db.getSiblingDB('admin');  
\> var dbs = db.adminCommand('listDatabases');  
\>  
\> dbs.databases.forEach(function(database){  
\> print("Database: " + database.name);  
\> print("-----");  
\> if (database.name == "config") { print("Skipped"); }  
\> else {  
\> db = db.getSiblingDB(database.name);  
\> db.getCollectionNames().forEach(function(collection) {  
\> print("Collection '" + collection + "' documents: " + db\[collection\].count());  
\> });  
\> };  
\> print("");  
\> });  
\>  
\> exit  
\> EOF  
admin 0.000GB  
config 0.000GB  
endpoint-server 0.003GB  
local 0.000GB  
admin  
Database: admin  
\-----  
Collection 'system.users' documents: 23  
Collection 'system.version' documents: 2

Database: config  
\-----  
Skipped

Database: endpoint-server  
\-----  
Collection 'bookmark' documents: 11  
Collection 'certificate' documents: 95  
Collection 'command' documents: 134  
Collection 'file' documents: 1451  
Collection 'filecontexthistory' documents: 1367  
Collection 'grouppolicy' documents: 1  
Collection 'machinedetail' documents: 2  
Collection 'machinefile' documents: 1  
Collection 'machinefilehistory' documents: 0  
Collection 'machinefilescore' documents: 0  
Collection 'machinefilestage' documents: 0  
Collection 'machinehistory' documents: 1  
Collection 'machineidentity' documents: 2  
Collection 'mftrecord' documents: 0  
Collection 'relayconfig' documents: 1

Database: local  
\-----  
Collection 'startup\_log' documents: 15

The output shows :

- The disk space size of all databases in the mongodb,
- The "show dbs" output
- For each database, there is a count of the documents in each collection.

This information can be useful to determine the databases using the most disk space and the collections with the most entries.

Note: The config database is skipped as it is for internal use by the mongod service and this command has insufficient permission to access.

#### Product Details

**Product Set:**  NetWitness Logs & Network  
**Product/Service Type:** Mongodb, Admin-Server, ESA, Endpoint-Server  
**RSA Version/Condition:** 11.x, 12.x  
**Platform:** CentOS, AlmaLinux

#### Summary

Which NetWitness mongodb database has the most documents?

#### Approval Reviewer Queue

Technical approval queue

[![Netwitness Logo](https://mydev.netwitness.com/hs-fs/hubfs/Quote%20Template%20-%20NW%20Logo/Netwitness%20Logo.png?width=158&height=42&name=Netwitness%20Logo.png "Netwitness Logo")](https://mydev.netwitness.com/?hsLang=en)

<https://www.linkedin.com/company/netwitness-platform/> <https://www.youtube.com/@netwitness>

Copyright © 2026, NetWitness LLC. All rights reserved.

[NetWitness Platform](https://www.netwitness.com/)

[Acceptable Use Policy](https://www.netwitness.com/wp-content/uploads/Acceptable-Use-Policy-092022.pdf) [Privacy Statement](https://www.netwitness.com/wp-content/uploads/NetWitness-Privacy-Statement-07292024.pdf)

![NetWitness Logo](https://mydev.netwitness.com/hubfs/Portal-Partner%20Program/netwitness-logo-RGB-white%201.png)

[![LinkedIn](https://mydev.netwitness.com/hubfs/Portal-Partner%20Program/linkedin.png)](https://www.linkedin.com/company/netwitness-platform/) [![YouTube](https://mydev.netwitness.com/hubfs/Portal-Partner%20Program/Youtube.jpg)](https://www.youtube.com/@netwitness)

© 2026 NetWitness LLC. All rights reserved.