> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

<!--
Tab options on this page. Append to the .md URL to filter:
  ?tabs=<id,...>   select specific tabs (e.g. ?tabs=nodejs,shell)
  ?allTabs=true    include every tab
  (no param)       default: one tab per tabset

Available tabs:
  other tabs: dialog-box, search-box
-->

# Monitor Collection-Level Query Latency with Namespace Insights

*Only available on M10+ clusters*

Monitor collection-level [query latency](https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#latencystats-document) with Namespace Insights. The Namespace Insights page displays two charts and a table with information for each top or pinned [namespace](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-namespace). The information includes metrics and statistics for certain hosts and operation types. You can manage pinned namespaces and choose up to five namespaces to show in the corresponding query latency charts.

## Required Access

To view collection-level query latency with Namespace Insights, you must have [`Project Read Only`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Project-Read-Only), [`Project Observability Viewer`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Project-Observability-Viewer), [`Project Data Access Read Only`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Project-Data-Access-Read-Only), [`Project Data Access Read/Write`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Project-Data-Access-Read-Write), or [`Project Data Access Admin`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Project-Data-Access-Admin) access to the project.

## Considerations

- The Namespace Insights tab is supported only for Atlas M10+ clusters.

- If you have [Queryable Encryption](https://www.mongodb.com/docs/manual/core/queryable-encryption/) enabled for a collection, Namespace Insights doesn't display the collection in this location. Atlas redacts this information.

- Atlas displays top namespaces by default. Depending on the time range, a namespace might fall in and out of the monitored list. Atlas interpolates missing data when at least one host metric exists in both ends of the time range. If Atlas encounters missing data, dotted lines connect the available data points.

- If you reach the data limit for a page load, the following error message appears:

  ```text
  Chart data limit reached. Try a smaller time window or fewer hosts.
  ```

- The Namespace Insights tab doesn't support [time series collections.](https://www.mongodb.com/docs/manual/core/timeseries-collections/)

##### High-Latency $lookup Operations

Some high-latency [`$lookup`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup.md#mongodb-pipeline-pipe.-lookup) operations don't generate a slow query log for the foreign collection. This can occur because slow query logs correspond with operations that are reported in the [Query Profiler](https://www.mongodb.com/docs/atlas/tutorial/query-profiler.md#std-label-query-profiler), whereas latency metrics increment only when a [collection lock](https://www.mongodb.com/docs/manual/faq/concurrency.md#std-label-faq-concurrency-locking) is acquired.

If the `$lookup` query on a shard can perform a local read, the `$lookup` doesn't record a separate operation for querying the foreign collection. A local read refers to when the query on the foreign collection targets only the same shard where the current operation is being executed. As a result, the `$lookup` operation increases the Namespace Insights latency metrics and operation counts, but does not generate a slow query log for the foreign collection.

## Access Namespace Insights

To access Namespace Insights:

1. In Atlas, go to the Clusters page for your project.

   If it's not already displayed, select the organization that contains your desired project from the  Organizations menu in the navigation bar.

   If it's not already displayed, select your desired project from the Projects menu in the navigation bar.

   In the sidebar, click Clusters under the Database heading.

   The [Clusters](https://cloud.mongodb.com/go?l=https%3A%2F%2Fcloud.mongodb.com%2Fv2%2F%3Cproject%3E%23%2Fclusters) page displays.

2. Go to Namespace Insights.

   Click the name of the cluster to open the Cluster sidebar.

   Click Query Insights in the Cluster sidebar.

   The Query Shapes tab displays by default.

   Click the Namespace tab.

## Filter Query Insights

You can filter the Query Insights page by node, node state (primary or secondary), and shard. You can also filter by a custom date range within the last seven days, or select one of the following preset time ranges:

- 7 days

- 5 days

- 2 days

- 24 hours (default)

- 12 hours

- 8 hours

- 1 hour

When you apply a filter, Atlas re-fetches data for the charts and table on the current screen.

**Note:**

[Analytics nodes](https://www.mongodb.com/docs/atlas/cluster-config/multi-cloud-distribution.md#std-label-add-analytics-node) are included when you filter by secondary node state.

## View Metrics in Charts

The Namespace Insights page displays two charts that each visualize a selected metric for up to five selected namespaces over the filtered time range.

By default, Atlas charts metrics for pinned namespaces and top namespaces with the highest total latency. To choose which namespaces to chart, see [Select Namespaces to Chart](https://www.mongodb.com/docs/atlas/namespace-insights.md#std-label-select-namespaces-to-chart). To find and pin namespaces, see [Manage Pinned Namespaces.](https://www.mongodb.com/docs/atlas/namespace-insights.md#std-label-manage-pinned-namespaces)

To select which metrics to visualize and filter by operation type:

1. Select the metrics to display.

   Select one of the following metrics:

   | Metric | Description |
   | --- | --- |
   | Total latency | Rate that indicates the total combined server operation duration on a collection (total combined server operation duration / collection interval in seconds). |
   | Average latency | Difference between two server operation times, collected 10 minutes apart, divided by the difference between two total server operation count values collected over the same 10-minute interval. |
   | P50 latency | 50th percentile in the [latency histogram.](https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#latencystats-document) |
   | P95 latency | 95th percentile in the [latency histogram.](https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#latencystats-document) |
   | P99 latency | 99th percentile in the [latency histogram.](https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#latencystats-document) |
   | Operation count | Rate that indicates the total number of server operations performed on a collection  (total server operations / collection interval) |

2. Select the operation type to display.

   Select one of the following operation types:

   - All operation types

   - Read

   - Write

   - Command

## Manage Pinned Namespaces

You can search and pin a maximum of five namespaces to the top of the table from the Pinned Namespace dialog box or Search namespaces search box.

### Dialog Box

To manage pinned namespaces from the Pinned Namespace dialog box:

1. Open the Pinned Namespaces dialog box.

   - If you have no pinned namespaces, click the Pin namespaces button.

   - If you have pinned namespaces, click the Manage pinned namespaces button.

   The Pinned Namespaces dialog box displays.

2. Search the namespaces.

   Specify a namespace in the Enter namespaces to pin search box. You can also pin planned namespaces that don't exist yet.

3. Pin the namespace.

   Click the namespace that you want to pin.

4. (Optional) Unpin a namespace.

   Click Unpin next to the namespace that you want to unpin.

## Select Namespaces to Chart

Atlas displays up to five namespaces. It displays pinned namespaces (if any) and then top namespaces with the highest total latency by default. You can also manually select the namespaces to chart.

To select namespaces:

1. Search the table.

   Specify a namespace in the Search namespaces search box.

2. Select the namespace to display in the charts.

   Click the checkbox next to the namespace.

   **Note:**

   You can select a maximum of five namespaces. If you have five namespaces and want to display another, you must deselect one.

## Edit Columns

Atlas displays the following table columns by default for pinned namespaces (if any) and top namespaces:

- Total latency for all operation types

- Average latency for all operation types

- P95 latency for all operation types

- Operation Count for all operation types

To adjust the metric and operation type columns:

1. Expand the Edit Columns drop-down.

   Click the Edit Columns button.

2. Select the columns to display and hide.

   Expand the metrics to display or hide.

   Select the operation types to display.

   Deselect the operation types to hide.

3. View the columns.

   Click inside the table to close the drop-down.

   Scroll to the right to view columns beyond the edge of the screen width.

## Go to a Collection

You can go to a collection in the Atlas UI from the table.

To go to a collection:

1. Search the table.

   Specify a namespace in the Search namespaces search box.

2. Go to a collection.

   Click the  icon next to the namespace for the collection that you want to view.

   Click Go to collection.
