Skip to content
v2.278.0

DatabaseInstanceMetrics Class ​

CloudWatch metrics for a database instance.

Works with any reference to a database instance: a DatabaseInstance, an imported instance or a CfnDBInstance.

Example ​

ts
declare const instance: rds.IDatabaseInstance;

const metrics = rds.DatabaseInstanceMetrics.fromDatabaseInstance(instance);

// How far a read replica lags behind its source (average over 5 minutes)
const replicaLag = metrics.replicaLag();

// The average amount of time taken per disk I/O read operation (average over 1 minute)
const readLatency = metrics.readLatency({ period: Duration.seconds(60) });

// Any other metric, such as an engine-specific one
const binLogDiskUsage = metrics.metric('BinLogDiskUsage', { statistic: 'Maximum' });
python
# instance: rds.IDatabaseInstance


metrics = rds.DatabaseInstanceMetrics.from_database_instance(instance)

# How far a read replica lags behind its source (average over 5 minutes)
replica_lag = metrics.replica_lag()

# The average amount of time taken per disk I/O read operation (average over 1 minute)
read_latency = metrics.read_latency(period=Duration.seconds(60))

# Any other metric, such as an engine-specific one
bin_log_disk_usage = metrics.metric("BinLogDiskUsage", statistic="Maximum")
java
IDatabaseInstance instance;


DatabaseInstanceMetrics metrics = DatabaseInstanceMetrics.fromDatabaseInstance(instance);

// How far a read replica lags behind its source (average over 5 minutes)
Metric replicaLag = metrics.replicaLag();

// The average amount of time taken per disk I/O read operation (average over 1 minute)
Metric readLatency = metrics.readLatency(MetricOptions.builder().period(Duration.seconds(60)).build());

// Any other metric, such as an engine-specific one
Metric binLogDiskUsage = metrics.metric("BinLogDiskUsage", MetricOptions.builder().statistic("Maximum").build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
IDatabaseInstance instance;


var metrics = DatabaseInstanceMetrics.FromDatabaseInstance(instance);

// How far a read replica lags behind its source (average over 5 minutes)
var replicaLag = metrics.ReplicaLag();

// The average amount of time taken per disk I/O read operation (average over 1 minute)
var readLatency = metrics.ReadLatency(new MetricOptions { Period = Duration.Seconds(60) });

// Any other metric, such as an engine-specific one
var binLogDiskUsage = metrics.Metric("BinLogDiskUsage", new MetricOptions { Statistic = "Maximum" });
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var instance IDatabaseInstance


metrics := rds.DatabaseInstanceMetrics_FromDatabaseInstance(instance)

// How far a read replica lags behind its source (average over 5 minutes)
replicaLag := metrics.ReplicaLag()

// The average amount of time taken per disk I/O read operation (average over 1 minute)
readLatency := metrics.ReadLatency(&MetricOptions{
	Period: awscdk.Duration_Seconds(jsii.Number(60)),
})

// Any other metric, such as an engine-specific one
binLogDiskUsage := metrics.Metric(jsii.String("BinLogDiskUsage"), &MetricOptions{
	Statistic: jsii.String("Maximum"),
})

Methods ​

burstBalance(props?: MetricOptions): Metricdef burst_balance(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric burstBalance(MetricOptions props)public Metric BurstBalance(MetricOptions? props = null)func BurstBalance(Props MetricOptions) Metric #
The percent of burst-bucket I/O credits available.

This metric is available for DB instances that use General Purpose SSD (gp2) storage.

cpuUtilization(props?: MetricOptions): Metricdef cpu_utilization(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric cpuUtilization(MetricOptions props)public Metric CpuUtilization(MetricOptions? props = null)func CpuUtilization(Props MetricOptions) Metric #
The percentage of CPU utilization.
databaseConnections(props?: MetricOptions): Metricdef database_connections(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric databaseConnections(MetricOptions props)public Metric DatabaseConnections(MetricOptions? props = null)func DatabaseConnections(Props MetricOptions) Metric #
The number of client network connections to the database instance.
diskQueueDepth(props?: MetricOptions): Metricdef disk_queue_depth(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric diskQueueDepth(MetricOptions props)public Metric DiskQueueDepth(MetricOptions? props = null)func DiskQueueDepth(Props MetricOptions) Metric #
The number of outstanding I/Os (read/write requests) waiting to access the disk.
freeableMemory(props?: MetricOptions): Metricdef freeable_memory(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric freeableMemory(MetricOptions props)public Metric FreeableMemory(MetricOptions? props = null)func FreeableMemory(Props MetricOptions) Metric #
The amount of available random access memory.
freeStorageSpace(props?: MetricOptions): Metricdef free_storage_space(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric freeStorageSpace(MetricOptions props)public Metric FreeStorageSpace(MetricOptions? props = null)func FreeStorageSpace(Props MetricOptions) Metric #
The amount of available storage space.
fromDatabaseInstance(instance: IDBInstanceRef): DatabaseInstanceMetrics // chainable@staticmethod def from_database_instance(instance: IDBInstanceRef) -> DatabaseInstanceMetricspublic static DatabaseInstanceMetrics fromDatabaseInstance(IDBInstanceRef instance)public static DatabaseInstanceMetrics FromDatabaseInstance(IDBInstanceRef instance)func FromDatabaseInstance(Instance IDBInstanceRef) DatabaseInstanceMetrics static #
Creates the metrics for the given database instance.
1 parameter

Parameters

  • instanceinstanceinstanceinstanceInstance — The database instance to create the metrics for.
metric(metricName: string, props?: MetricOptions): Metricdef metric(self, metric_name: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metric(String metricName, MetricOptions props)public Metric Metric(string metricName, MetricOptions? props = null)func Metric(MetricName *string, Props MetricOptions) Metric #
Return the given named metric for this database instance.

If dimensionsMap is set, it replaces the default DBInstanceIdentifier dimension, so the metric no longer refers to this instance unless the new dimensions include it.

2 parameters

Parameters

  • metricNamemetric_namemetricNamemetricNameMetricName — The name of the metric in the AWS/RDS namespace.
  • propspropspropspropsProps — Properties to override on the metric.
networkReceiveThroughput(props?: MetricOptions): Metricdef network_receive_throughput(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric networkReceiveThroughput(MetricOptions props)public Metric NetworkReceiveThroughput(MetricOptions? props = null)func NetworkReceiveThroughput(Props MetricOptions) Metric #
The incoming (receive) network traffic on the DB instance, including both customer database traffic and Amazon RDS traffic used for monitoring and replication.
networkTransmitThroughput(props?: MetricOptions): Metricdef network_transmit_throughput(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric networkTransmitThroughput(MetricOptions props)public Metric NetworkTransmitThroughput(MetricOptions? props = null)func NetworkTransmitThroughput(Props MetricOptions) Metric #
The outgoing (transmit) network traffic on the DB instance, including both customer database traffic and Amazon RDS traffic used for monitoring and replication.
readIOPS(props?: MetricOptions): Metricdef read_iops(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric readIOPS(MetricOptions props)public Metric ReadIOPS(MetricOptions? props = null)func ReadIOPS(Props MetricOptions) Metric #
The average number of disk read I/O operations per second.
readLatency(props?: MetricOptions): Metricdef read_latency(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric readLatency(MetricOptions props)public Metric ReadLatency(MetricOptions? props = null)func ReadLatency(Props MetricOptions) Metric #
The average amount of time taken per disk I/O read operation.
readThroughput(props?: MetricOptions): Metricdef read_throughput(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric readThroughput(MetricOptions props)public Metric ReadThroughput(MetricOptions? props = null)func ReadThroughput(Props MetricOptions) Metric #
The average number of bytes read from disk per second.
replicaLag(props?: MetricOptions): Metricdef replica_lag(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric replicaLag(MetricOptions props)public Metric ReplicaLag(MetricOptions? props = null)func ReplicaLag(Props MetricOptions) Metric #
For read replica configurations, the amount of time a read replica DB instance lags behind the source DB instance.

This metric is available for MariaDB, Microsoft SQL Server, MySQL, Oracle, and PostgreSQL read replicas.

swapUsage(props?: MetricOptions): Metricdef swap_usage(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric swapUsage(MetricOptions props)public Metric SwapUsage(MetricOptions? props = null)func SwapUsage(Props MetricOptions) Metric #
The amount of swap space used on the DB instance.

This metric is available for MariaDB, MySQL, Oracle, and PostgreSQL DB instances.

writeIOPS(props?: MetricOptions): Metricdef write_iops(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric writeIOPS(MetricOptions props)public Metric WriteIOPS(MetricOptions? props = null)func WriteIOPS(Props MetricOptions) Metric #
The average number of disk write I/O operations per second.
writeLatency(props?: MetricOptions): Metricdef write_latency(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric writeLatency(MetricOptions props)public Metric WriteLatency(MetricOptions? props = null)func WriteLatency(Props MetricOptions) Metric #
The average amount of time taken per disk I/O write operation.
writeThroughput(props?: MetricOptions): Metricdef write_throughput(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric writeThroughput(MetricOptions props)public Metric WriteThroughput(MetricOptions? props = null)func WriteThroughput(Props MetricOptions) Metric #
The average number of bytes written to disk per second.