Monitoring Amazon DocumentDB with CloudWatch

Amazon DocumentDB (with MongoDB compatibility) integrates with Amazon CloudWatch so that you can gather and analyze operational metrics for your clusters. You can monitor these metrics using the CloudWatch console, the Amazon DocumentDB console, the AWS Command Line Interface (AWS CLI), or the CloudWatch API.

CloudWatch also lets you set alarms so that you can be notified if a metric value breaches a threshold that you specify. You can even set up Amazon CloudWatch Events to take corrective action if a breach occurs. For more information about using CloudWatch and alarms, see the Amazon CloudWatch documentation.

Amazon DocumentDB Metrics

To monitor the health and performance of your Amazon DocumentDB cluster and instances, you can view the following metrics in the Amazon DocumentDB console.

MetricDescription
Resource Utilization
BackupRetentionPeriodStorageUsedThe total amount of backup storage in GiB used to support the point-in-time restore feature within the Amazon DocumentDB’s retention window. Included in the total reported by the TotalBackupStorageBilled metric. Computed separately for each Amazon DocumentDB cluster.
ChangeStreamLogSizeThe amount of storage used by your cluster to store the change stream log in megabytes. This value is a subset of the total storage for the cluster (VolumeBytesUsed) and affects the cost of the cluster. For storage pricing information, see the Amazon DocumentDB product page. The change stream log size is a function of how much change is happening on your cluster and the change stream long retention duration. For more information on change streams, see Using Change Streams with Amazon DocumentDB.
CPUUtilizationThe percentage of CPU used by an instance.
DatabaseConnectionsThe number of connections open on an instance taken at a one-minute frequency.
DatabaseConnectionsMaxThe maximum number of open database connections on an instance in a one-minute period.
DatabaseCursorsThe number of cursors open on an instance taken at a one-minute frequency.
DatabaseCursorsMaxThe maximum number of open cursors on an instance in a one-minute period.
DatabaseCursorsTimedOutThe number of cursors that timed out in a one-minute period.
FreeableMemoryThe amount of available random access memory, in bytes.
FreeLocalStorage

This metric reports the amount of storage available to each instance for temporary tables and logs. This value depends on the instance class. You can increase the amount of free storage space for an instance by choosing a larger instance class for your instance.

LowMemThrottleQueueDepth

The queue depth for requests that are throttled due to low available memory taken at a one-minute frequency.

LowMemThrottleMaxQueueDepth

The maximum queue depth for requests that are throttled due to low available memory in a one-minute period.

LowMemNumOperationsThrottled

The number of requests that are throttled due to low available memory in a one-minute period.

SnapshotStorageUsedThe total amount of backup storage in GiB consumed by all snapshots for a given Amazon DocumentDB cluster outside its backup retention window. Included in the total reported by the TotalBackupStorageBilled metric. Computed separately for each Amazon DocumentDB cluster.
SwapUsageThe amount of swap space used on the instance.
TotalBackupStorageBilledThe total amount of backup storage in GiB for which you are billed for a given Amazon DocumentDB cluster. Includes the backup storage measured by the BackupRetentionPeriodStorageUsed and SnapshotStorageUsed metrics. Computed separately for each Amazon DocumentDB cluster.
TransactionsOpenThe number of transactions open on an instance taken at a one-minute frequency.
TransactionsOpenMaxThe maximum number of transactions open on an instance in a one-minute period.
VolumeBytesUsedThe amount of storage used by your cluster in bytes. This value affects the cost of the cluster. For pricing information, see the Amazon DocumentDB product page.
Latency
DBClusterReplicaLagMaximumThe maximum amount of lag, in milliseconds, between the primary instance and each Amazon DocumentDB instance in the cluster.
DBClusterReplicaLagMinimumThe minimum amount of lag, in milliseconds, between the primary instance and each replica instance in the cluster.
DBInstanceReplicaLagThe amount of lag, in milliseconds, when replicating updates from the primary instance to a replica instance.
ReadLatencyThe average amount of time taken per disk I/O operation.
WriteLatencyThe average amount of time, in milliseconds, taken per disk I/O operation.
Operations
DocumentsDeletedThe number of deleted documents in a one-minute period.
DocumentsInsertedThe number of inserted documents in a one-minute period.
DocumentsReturnedThe number of returned documents in a one-minute period.
DocumentsUpdatedThe number of updated documents in a one-minute period.
OpcountersCommandThe number of commands issued in a one-minute period.
OpcountersDeleteThe number of delete operations issued in a one-minute period.
OpcountersGetmoreThe number of getmores issued in a one-minute period.
OpcountersInsertThe number of insert operations issued in a one-minute period.
OpcountersQueryThe number of queries issued in a one-minute period.
OpcountersUpdateThe number of update operations issued in a one-minute period.
TransactionsStartedThe number of transactions started on an instance in a one-minute period.
TransactionsCommittedThe number of transactions committed on an instance in a one-minute period.
TransactionsAbortedThe number of transactions aborted on an instance in a one-minute period.
TTLDeletedDocumentsThe number of documents deleted by a TTLMonitor in a one-minute period.
Throughput
NetworkReceiveThroughputThe amount of network throughput, in bytes per second, received from clients by each instance in the cluster. This throughput doesn’t include network traffic between instances in the cluster and the cluster volume.
NetworkThroughputThe amount of network throughput, in bytes per second, both received from and transmitted to clients by each instance in the Amazon DocumentDB cluster. This throughput doesn’t include network traffic between instances in the cluster and the cluster volume.
NetworkTransmitThroughputThe amount of network throughput, in bytes per second, sent to clients by each instance in the cluster. This throughput doesn’t include network traffic between instances in the cluster and the cluster volume.
ReadIOPSThe average number of disk read I/O operations per second. Amazon DocumentDB reports read and write IOPS separately, and on one-minute intervals.
ReadThroughputThe average number of bytes read from disk per second.
VolumeReadIOPsThe average number of billed read I/O operations from a cluster volume, reported at 5-minute intervals. Billed read operations are calculated at the cluster volume level, aggregated from all instances in the cluster, and then reported at 5-minute intervals. The value is calculated by taking the value of the read operations metric over a 5-minute period. You can determine the amount of billed read operations per second by taking the value of the billed read operations metric and dividing by 300 seconds. For example, if the billed read operations returns 13,686, then the billed read operations per second is 45 (13,686 / 300 = 45.62). You accrue billed read operations for queries that request database pages that are not present in the buffer cache and therefore must be loaded from storage. You might see spikes in billed read operations as query results are read from storage and then loaded into the buffer cache.
VolumeWriteIOPs

The average number of billed write I/O operations from a cluster volume, reported at 5-minute intervals. Billed write operations are calculated at the cluster volume level, aggregated from all instances in the cluster, and then reported at 5-minute intervals. The value is calculated by taking the value of the write operations metric over a 5-minute period. You can determine the amount of billed write operations per second by taking the value of the billed write operations metric and dividing by 300 seconds. For example, if the billed write operations returns 13,686, then the billed write operations per second is 45 (13,686 / 300 = 45.62).

Note that VolumeReadIOPs and VolumeWriteIOPs metrics are calculated by the DocumentDB storage layer and it includes IOs performed by the primary and replica instances. The data is aggregated every 20-30 minutes and then reported at 5-minute intervals, thus emitting the same data point for the metric in the time period. If you are looking for a metric to correlate to your insert operations over a 1-minute interval, you can use the instance level WriteIOPS metric. The metric is available in the monitoring tab of your Amazon DocumentDB primary instance.

WriteIOPSThe average number of disk write I/O operations per second. Read and write IOPS are reported separately, on 1-minute intervals.
WriteThroughputThe average number of bytes written to disk per second.
System
BufferCacheHitRatioThe percentage of requests that are served by the buffer cache.
DiskQueueDepththe number of concurrent write requests to the distributed storage volume.
EngineUptimeThe amount of time, in seconds, that the instance has been running.
IndexBufferCacheHitRatioThe percentage of index requests that are served by the buffer cache. You might see a spike greather than 100% for the metric right after you drop an index, collection or database. This will automatically be corrected after 60 seconds. This limitation will be fixed in a future patch update.
T3 Instance Metrics
CPUCreditUsageThe number of CPU credits spent during the measurement period.
CPUCreditBalanceThe number of CPU credits that an instance has accrued. This balance is depleted when the CPU bursts and CPU credits are spent more quickly than they are earned.
CPUSurplusCreditBalanceThe number of surplus CPU credits spent to sustain CPU performance when the CPUCreditBalance value is zero.
CPUSurplusCreditsChargedThe number of surplus CPU credits exceeding the maximum number of CPU credits that can be earned in a 24-hour period, and thus attracting an additional charge. For more information, see Monitoring your CPU credits.

Viewing CloudWatch Data

You can view Amazon CloudWatch data using the CloudWatch console, the Amazon DocumentDB console, AWS Command Line Interface (AWS CLI), or the CloudWatch API.

To view CloudWatch metrics using the Amazon DocumentDB Management Console, complete the following steps.

  1. Sign in to the AWS Management Console, and open the Amazon DocumentDB console at https://console.aws.amazon.com/docdb.

  2. In the navigation pane, choose Clusters.

    Tip

    If you don’t see the navigation pane on the left side of your screen, choose the menu icon (Monitoring Amazon DocumentDB with CloudWatch - 图1) in the upper-left corner of the page.

  3. In the Clusters navigation box, you’ll see the column Cluster Identifier. Your instances are listed under clusters, similar to the screenshot below.

    Monitoring Amazon DocumentDB with CloudWatch - 图2

  4. From the list of instances, choose the name of the instance that you want metrics for.

  5. In the resulting instance summary page, choose the Monitoring tab to view graphical representations of your Amazon DocumentDB instance’s metrics. Because a graph must be generated for each metric, it might take a few minutes for the CloudWatch graphs to populate.

    The following image shows the graphical representations of two CloudWatch metrics in the Amazon DocumentDB console, WriteIOPS and ReadIOPS.

    ![

    1. Two of the 18 CloudWatch metrics in the Amazon DocumentDB console,
    2. writeiops and readiops.
    3. ](/projects/DocumentDB-20201111-en/50e0cedef3945b0631ae9a4d22a081aa.png)

To view CloudWatch metrics using the CloudWatch Management Console, complete the following steps.

  1. Sign in to the AWS Management Console, and open the Amazon DocumentDB console at https://console.aws.amazon.com/cloudwatch.

  2. In the navigation pane, choose Metrics. Then, from the list of service names, choose DocDB.

  3. Choose a metric dimension (for example, Cluster Metrics).

  4. The All metrics tab displays all metrics for that dimension in DocDB.

    1. To sort the table, use the column heading.

    2. To graph a metric, select the check box next to the metric. To select all metrics, select the check box in the heading row of the table.

    3. To filter by metric, hover over the metric name and select the drop-down arrow next tot he metric name. Then, choose Add to search, as shown in the image below.

      ![

      1. Filter for a metric by hovering over the
      2. metric and selecting "Add to search".
      3. ](/projects/DocumentDB-20201111-en/fdf65743bb13c8dd32bd4f915cca6d46.png)

To view CloudWatch data for Amazon DocumentDB, use the CloudWatch get-metric-statistics operation with the following parameters.

Parameters

  • --namespace — Required. The service namespace for which you want CloudWatch metrics. For Amazon DocumentDB, this must be AWS/DocDB.

  • --metric-name — Required. The name of the metric for which you want data.

  • --start-time — Required. The timestamp that determines the first data point to return.

    The value specified is inclusive; results include data points with the specified timestamp. The timestamp must be in ISO 8601 UTC format (for example, 2016-10-03T23:00:00Z).

  • --end-time — Required. The timestamp that determines the last data point to return.

    The value specified is inclusive; results include data points with the specified timestamp. The timestamp must be in ISO 8601 UTC format (for example, 2016-10-03T23:00:00Z).

  • --period — Required. The granularity, in seconds, of the returned data points. For metrics with regular resolution, a period can be as short as one minute (60 seconds) and must be a multiple of 60. For high-resolution metrics that are collected at intervals of less than one minute, the period can be 1, 5, 10, 30, 60, or any multiple of 60.

  • --dimensions — Optional. If the metric contains multiple dimensions, you must include a value for each dimension. CloudWatch treats each unique combination of dimensions as a separate metric. If a specific combination of dimensions was not published, you can’t retrieve statistics for it. You must specify the same dimensions that were used when the metrics were created.

  • --statistics — Optional. The metric statistics, other than percentile. For percentile statistics, use ExtendedStatistics. When calling GetMetricStatistics, you must specify either Statistics or ExtendedStatistics, but not both.

    Permitted values:

    • SampleCount

    • Average

    • Sum

    • Minimum

    • Maximum

  • --extended-statistics — Optional. The percentile statistics. Specify values between p0.0 and p100. When calling GetMetricStatistics, you must specify either Statistics or ExtendedStatistics, but not both.

  • --unit — Optional. The unit for a given metric. Metrics may be reported in multiple units. Not supplying a unit results in all units being returned. If you specify only a unit that the metric does not report, the results of the call are null.

    Possible values:

    • Seconds

    • Microseconds

    • Milliseconds

    • Bytes

    • Kilobytes

    • Megabytes

    • Gigabytes

    • Terabytes

    • Bits

    • Kilobytes

    • Megabits

    • Gigabits

    • Terabits

    • Percent

    • Count

    • Bytes/Second

    • Kilobytes/Second

    • Megabytes/Second

    • Gigabytes/Second

    • Terabytes/Second

    • Bits/Second

    • Kilobits/Second

    • Megabits/Second

    • Gigabits/Second

    • Terabits/Second

    • Count/Second

    • None

The following example finds the maximum CPUUtilization for a 2-hour period taking a sample every 60 seconds.

For Linux, macOS, or Unix:

  1. aws cloudwatch get-metric-statistics \
  2. --namespace AWS/DocDB \
  3. --dimensions \
  4. Name=DBInstanceIdentifier,Value=docdb-2019-01-09-23-55-38 \
  5. --metric-name CPUUtilization \
  6. --start-time 2019-02-11T05:00:00Z \
  7. --end-time 2019-02-11T07:00:00Z \
  8. --period 60 \
  9. --statistics Maximum

For Windows:

  1. aws cloudwatch get-metric-statistics ^
  2. --namespace AWS/DocDB ^
  3. --dimensions ^
  4. Name=DBInstanceIdentifier,Value=docdb-2019-01-09-23-55-38 ^
  5. --metric-name CPUUtilization ^
  6. --start-time 2019-02-11T05:00:00Z ^
  7. --end-time 2019-02-11T07:00:00Z ^
  8. --period 60 ^
  9. --statistics Maximum

Output from this operation look something like the following.

  1. {
  2. "Label": "CPUUtilization",
  3. "Datapoints": [
  4. {
  5. "Unit": "Percent",
  6. "Maximum": 4.49152542374361,
  7. "Timestamp": "2019-02-11T05:51:00Z"
  8. },
  9. {
  10. "Unit": "Percent",
  11. "Maximum": 4.25000000000485,
  12. "Timestamp": "2019-02-11T06:44:00Z"
  13. },
  14. ********* some output omitted for brevity *********
  15. {
  16. "Unit": "Percent",
  17. "Maximum": 4.33333333331878,
  18. "Timestamp": "2019-02-11T06:07:00Z"
  19. }
  20. ]
  21. }

Amazon DocumentDB Dimensions

The metrics for Amazon DocumentDB are qualified by the values for the account or operation. You can use the CloudWatch console to retrieve Amazon DocumentDB data filtered by any of the dimensions in the following table.

DimensionDescription
DBClusterIdentifierFilters the data that you request for a specific Amazon DocumentDB cluster.
DBClusterIdentifier, RoleFilters the data that you request for a specific Amazon DocumentDB cluster, aggregating the metric by instance role (WRITER/READER). For example, you can aggregate metrics for all READER instances that belong to a cluster.
DBInstanceIdentifierFilters the data that you request for a specific database instance.

Monitoring Opcounters

Opcounter metrics have a non-zero value (usually ~50) for idle clusters. This is because Amazon DocumentDB performs periodic health checks, internal operations, and metrics collection tasks.

Monitoring Database Connections

When you view the number of connections by using database engine commands such as db.runCommand( { serverStatus: 1 }), you might see up to 10 more connections than you see in DatabaseConnections through CloudWatch. This occurs because Amazon DocumentDB performs periodic health checks and metrics collection tasks that don’t get accounted for in DatabaseConnections. DatabaseConnections represents customer-initiated connections only.