

# Analyzing metrics with the Performance Insights dashboard
<a name="performance-insights-analyzing"></a>

The Performance Insights dashboard contains database performance information to help you analyze and troubleshoot performance issues. On the main dashboard page, you can view information about the database load (DB load). You can "slice" DB load by dimensions such as wait states or query. 

**Topics**
+ [Overview of the Performance Insights dashboard](performance-insights-dashboard-overview.md)
+ [Opening the Performance Insights dashboard](performance-insights-dashboard-opening.md)
+ [Analyzing database load by wait states](performance-insights-analyzing-db-load.md)
+ [Overview of the Top queries tab](performance-insights-top-queries.md)
+ [Zooming in on the database load chart](performance-insights-zoom-db-load.md)

# Overview of the Performance Insights dashboard
<a name="performance-insights-dashboard-overview"></a>

The dashboard is the easiest way to interact with Performance Insights. The following example shows the dashboard for an Amazon DocumentDB instance. By default, the Performance Insights dashboard shows data for the last hour.

![\[Performance Insights dashboard showing CPU utilization and database load over time for an Amazon DocumentDB instance.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/overview-dashboard.png)


The dashboard is divided into the following parts:

1. **Counter metrics** – Shows data for specific performance counter metrics.

1. **Database load** – Shows how the DB load compares to DB instance capacity as represented by the **Max vCPU** line.

1.  **Top dimensions** – Shows the top dimensions contributing to DB load. These dimensions include `waits`, `queries`, `hosts`, `databases`, and `applications`.

**Topics**
+ [Counter metrics chart](#performance-insights-overview-metrics)
+ [Database load chart](#performance-insights-overview-db-load-chart)
+ [Top dimensions table](#performance-insights-overview-top-dimensions)

## Counter metrics chart
<a name="performance-insights-overview-metrics"></a>

With counter metrics, you can customize the Performance Insights dashboard to include up to 10 additional graphs. These graphs show a selection of dozens of operating system metrics. You can correlate this information with DB load to help identify and analyze performance problems.

The **Counter metrics** chart displays data for performance counters.

![\[Counter metrics chart showing CPU utilization over time.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/counter-metrics.png)


To change the performance counters, choose **Manage metrics**. You can select multiple **OS metrics** as shown in the following screenshot. To see details for any metric, hover over the metric name.

![\[Performance Insights dashboard metric selection interface with OS metrics options.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/overview-os-metrics.png)


## Database load chart
<a name="performance-insights-overview-db-load-chart"></a>

The **Database load** chart shows how the database activity compares to instance capacity as represented by the **Max vCPU** line. By default, the stacked line chart represents DB load as average active sessions per unit of time. The DB load is sliced (grouped) by wait states.

![\[Database load chart showing average active sessions over time, with CPU usage spiking near the end.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/database-load.png)


**DB load sliced by dimensions**  
You can choose to display load as active sessions grouped by any supported dimensions. The following image shows the dimensions for the Amazon DocumentDB instance.

![\[Graph showing database load with various "Slice by" options displayed in a dropdown list.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/database-load-sliced.png)


**DB load details for a dimension item**  
To see details about a DB load item within a dimension, hover over the item name. The following image shows details for a query statement.

![\[Bar graph showing database load with additional details displayed upon hovering over an item name.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/database-load-details.png)


To see details for any item for the selected time period in the legend, hover over that item.

![\[Bar graph showing database load with additional details displayed upon hovering over a bar.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/database-load-hover.png)


## Top dimensions table
<a name="performance-insights-overview-top-dimensions"></a>

The **Top dimensions table** slices DB load by different dimensions. A dimension is a category or "slice by" for different characteristics of DB load. If the dimension is query, **Top queries **shows the query statements that contribute most to the DB load.

Choose any of the following dimension tabs.

![\[The Top queries dimensions tab showing the two top queries.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/top-dimensions.png)


The following table provides a brief description of each tab.


| Tab | Description | 
| --- | --- | 
|  Top waits  |   The event for which the database backend is waiting  | 
|  Top queries  |  The query statements that are currently running  | 
|  Top hosts  |  The host IP and port of the connected client  | 
|  Top databases  |  The name of the database to which the client is connected  | 
|  Top applications  |  The name of the application that is connected to the database  | 

To learn how to analyze queries by using the **Top queries** tab, see [Overview of the Top queries tab](performance-insights-top-queries.md).

# Opening the Performance Insights dashboard
<a name="performance-insights-dashboard-opening"></a>

**To view the Performance Insights dashboard in the AWS Management Console, use the following steps:**

1. Open the Performance Insights console at [https://console.aws.amazon.com/docdb/](https://console.aws.amazon.com/docdb/home#performance-insights).

1. Choose a DB instance. The Performance Insights dashboard is shown for that Amazon DocumentDB instance.

   For Amazon DocumentDB instances with Performance Insights enabled, you can also reach the dashboard by choosing the **Sessions** item in the list of instances. Under **Current activity**, the **Sessions** item shows the database load in average active sessions over the last five minutes. The bar graphically shows the load. When the bar is empty, the instance is idle. As the load increases, the bar fills with blue. When the load passes the number of virtual CPUs (vCPUs) on the instance class, the bar turns red, indicating a potential bottleneck.  
![\[The Clusters page showing an Amazon DocumentDB regional cluster and the CPU and current activity of each cluster instance.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/opening-clusters.png)

1. (Optional) Choose a different time interval by selecting a button in the upper right. For example, to change the interval to 1 hour, select **1h**.  
![\[Time interval buttons ranging from five minutes to one week.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/opening-time.png)

   In the following screenshot, the DB load interval is 1 hour.  
![\[Bar graph showing database load measured in average active sessions.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/opening-db-load.png)

1. To refresh your data automatically, enable **Auto refresh**.  
![\[The auto refresh button enabled, appearing next to the time interval buttons.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/opening-auto-refresh.png)

   The Performance Insight dashboard automatically refreshes with new data. The refresh rate depends on the amount of data displayed: 
   + 5 minutes refreshes every 5 seconds.
   + 1 hour refreshes every minute.
   + 5 hours refreshes every minute.
   + 24 hours refreshes every 5 minutes.
   + 1 week refreshes every hour.

# Analyzing database load by wait states
<a name="performance-insights-analyzing-db-load"></a>

If the **Database load (DB load)** chart shows a bottleneck, you can find out where the load is coming from. To do so, look at the top load items table below the **Database load** chart. Choose a particular item, like a query or an application, to drill down into that item and see details about it.

DB load grouped by waits and top queries typically provides the most insight into performance issues. DB load grouped by waits shows if there are any resource or concurrency bottlenecks in the database. In this case, the **Top queries** tab of the top load items table shows which queries are driving that load.

Your typical workflow for diagnosing performance issues is as follows:

1. Review the **Database load** chart and see if there are any incidents of database load exceeding the **Max CPU** line.

1. If there is, look at the **Database load** chart and identify which wait state or states are primarily responsible.

1. Identify the digest queries causing the load by seeing which of the queries the **Top queries** tab on the top load items table are contributing most to those wait states. You can identify these by the **Load by Wait (AAS)** column.

1. Choose one of these digest queries in the **Top queries** tab to expand it and see the child queries that it is composed of.

You can also see which hosts or applications are contributing the most load by selecting **Top hosts** or **Top applications**, respectively. Application names are specified in the connection string to the Amazon DocumentDB instance. `Unknown` indicates that the application field was not specified. 

For example, in the following dashboard, **CPU** waits account for most of the DB load. Selecting the top query under **Top queries** will scope the Database load chart to focus on the most load that is being contributed by the select query.

![\[Database load chart showing CPU usage spike. A corresponding Top queries tab shows queries contributing the most to wait states.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/db-load-1.png)


![\[Database load chart showing CPU usage spike for the query contributing the most to wait states. A corresponding Top queries tab shows that query's child queries.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/db-load-2.png)


# Overview of the Top queries tab
<a name="performance-insights-top-queries"></a>

By default, the **Top query** tab shows the queries that are contributing the most to DB load. You can analyze the query text to help tune your queries.

**Topics**
+ [Query digests](#performance-insights-top-queries-digests)
+ [Load by waits (AAS)](#performance-insights-top-queries-aas)
+ [Viewing detailed query information](#performance-insights-top-queries-query-info)
+ [Accessing statement query text](#performance-insights-top-queries-accessing-text)
+ [Viewing and downloading statement query text](#performance-insights-top-queries-viewing-downloading)

## Query digests
<a name="performance-insights-top-queries-digests"></a>

A *query digest* is a composite of multiple actual queries that are structurally similar but might have different literal values. The digest replaces hardcoded values with a question mark. For example, a query digest might look like this:

```
{"find":"customerscollection","filter":{"FirstName":"?"},"sort":{"key":{"$numberInt":"?"}},"limit":{"$numberInt":"?"}}
```

This digest might include the following child queries:

```
{"find":"customerscollection","filter":{"FirstName":"Karrie"},"sort":{"key":{"$numberInt":"1"}},"limit":{"$numberInt":"3"}}
{"find":"customerscollection","filter":{"FirstName":"Met"},"sort":{"key":{"$numberInt":"1"}},"limit":{"$numberInt":"3"}}
{"find":"customerscollection","filter":{"FirstName":"Rashin"},"sort":{"key":{"$numberInt":"1"}},"limit":{"$numberInt":"3"}}
```

To see the literal query statements in a digest, select the query, and then choose the plus symbol (`+`). In the following screenshot, the selected query is a digest.

![\[The Top queries table showing an expanded query digest with one child query selected.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/top-queries-literal.png)


**Note**  
A query digest groups similar query statements, but does not redact sensitive information. 

## Load by waits (AAS)
<a name="performance-insights-top-queries-aas"></a>

In **Top queries**, the **Load by waits (AAS)** column illustrates the percentage of the database load associated with each top load item. This column reflects the load for that item by whatever grouping is currently selected in the **DB load chart**. For example, you might group the **DB load chart** by wait states. In this case, the **DB Load by Waits** bar is sized, segmented, and color-coded to show how much of a given wait state that query is contributing to. It also shows which wait states are affecting the selected query.

![\[Bar chart showing database load grouped by CPU, IO, and latch wait states. The corresponding table shows the top queries based on load by wait.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/top-queries-aas.png)


## Viewing detailed query information
<a name="performance-insights-top-queries-query-info"></a>

In the **Top query** table, you can open a *digest statement* to view its information. The information appears in the bottom pane.

![\[The Top queries table showing a selected query statement and its query information below.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/top-queries-detailed.png)


The following types of identifiers (IDs) are associated with query statements:

1. **Support query ID** – A hash value of the query ID. This value is only for referencing a query ID when you are working with AWS Support. AWS Support doesn't have access to your actual query IDs and query text.

1. **Support digest ID** – A hash value of the digest ID. This value is only for referencing a digest ID when you are working with AWS Support. AWS Support doesn't have access to your actual digest IDs and query text.

## Accessing statement query text
<a name="performance-insights-top-queries-accessing-text"></a>

By default, each row in the **Top queries** table shows 500 bytes of query text for each query statement. When a digest statement exceeds 500 bytes, you can view more text by opening the statement in the Performance Insights dashboard. In this case, the maximum length for the displayed query is 1 KB. If you view a full query statement, you can also choose **Download**.

## Viewing and downloading statement query text
<a name="performance-insights-top-queries-viewing-downloading"></a>

In the Performance Insights dashboard, you can view or download query text.

**To view more query text in the Performance Insights dashboard**

1. Open the Amazon DocumentDB console at: [https://console.aws.amazon.com/docdb/](https://console.aws.amazon.com/docdb/) 

1. In the navigation pane, choose **Performance Insights**.

1. Choose a DB instance. The Performance Insights dashboard is displayed for that DB instance.

   Query statements with text larger than 500 bytes will look like the following image:  
![\[The Top queries table with a child query selected.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/top-queries-statement.png)

1. Examine the query information section to view more of the query text.  
![\[The Query information section showing the full text of the selected query.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/top-queries-query-text.png)

The Performance Insights dashboard can display up to 1 KB for each full query statement.

**Note**  
To copy or download the query statement, disable any pop-up blockers.

# Zooming in on the database load chart
<a name="performance-insights-zoom-db-load"></a>

You can use other features of the Performance Insights user interface to help analyze performance data.

**Click-and-Drag Zoom In**  
In the Performance Insights interface, you can choose a small portion of the load chart and zoom in on the detail.

![\[Bar chart showing database load, with a portion of it highlighted for zooming in.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/pi-zoom-1.png)


To zoom in on a portion of the load chart, choose the start time and drag to the end of the time period you want. When you do this, the selected area is highlighted. When you release the mouse, the load chart zooms in on the selected area, and the **Top *items*** table is recalculated.

![\[Database load bar chart showing zoomed-in portion, with corresponding Top waits table below.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/performance-insights/pi-zoom-2.png)
