@renovosolutions/cdk-library-cloudwatch-alarms
Version:
AWS CDK Construct Library to automatically create CloudWatch Alarms for resources in a CDK app based on resource type.
518 lines (517 loc) • 23.1 kB
TypeScript
import { IAspect, aws_elasticache as elasticache, aws_cloudwatch as cloudwatch, Duration } from 'aws-cdk-lib';
import { Construct, IConstruct } from 'constructs';
import { AlarmBaseProps } from './common';
/**
* The recommended metrics for ElastiCache alarms.
*/
export declare enum ElastiCacheRecommendedAlarmsMetrics {
/**
* Percentage of the memory for the cluster that is in use.
*/
DATABASE_MEMORY_USAGE_PERCENTAGE = "DatabaseMemoryUsagePercentage",
/**
* Provides CPU utilization of the Valkey or Redis OSS engine thread. Because Valkey and Redis OSS are single-threaded,
* you can use this metric to analyze the load of the process itself. The `EngineCPUUtilization` metric provides a more
* precise visibility of the process. You can use it in conjunction with the `CPUUtilization` metric. `CPUUtilization`
* exposes CPU utilization for the server instance as a whole, including other operating system and management processes.
* For larger node types with four vCPUs or more, use the EngineCPUUtilization metric to monitor and set thresholds for scaling.
*/
ENGINE_CPU_UTILIZATION = "EngineCPUUtilization",
/**
* It represents how far behind, in seconds, the replica is in applying changes from the primary node. For Valkey 7.2 and onwards,
* and Redis OSS engine version 5.0.6 onwards, the lag can be measured in milliseconds.
*/
REPLICATION_LAG = "ReplicationLag"
}
/**
* The common optional configuration for the alarms.
*/
export interface ElastiCacheAlarmBaseConfig extends AlarmBaseProps {
/**
* The period over which the specified statistic is applied.
*
* @default Duration.minutes(1)
*/
readonly period?: Duration;
}
/**
* The common properties for the ElastiCache CfnCacheCluster alarms.
*/
export interface ElastiCacheClusterAlarmProps {
/**
* The ElastiCache CfnCacheCluster to monitor.
*/
readonly cacheCluster: elasticache.CfnCacheCluster;
}
/**
* The common properties for the ElastiCache CfnReplicationGroup alarms.
*/
export interface ElastiCacheReplicationGroupAlarmProps {
/**
* The ElastiCache CfnReplicationGroup to monitor.
*/
readonly cacheReplicationGroup: elasticache.CfnReplicationGroup;
}
/**
* Configuration for the DatabaseMemoryUsagePercentage alarm.
*/
export interface ElastiCacheDatabaseMemoryUsagePercentageAlarmConfig extends ElastiCacheAlarmBaseConfig {
/**
* Depending on your application's memory requirements and the memory capacity of your ElastiCache cluster,
* you should set the threshold to the percentage that reflects the critical level of memory usage of the cluster.
* You can use historical memory usage data as reference for acceptable memory usage threshold.
*/
readonly threshold: number;
/**
* The number of periods over which data is compared to the specified threshold.
*
* @default 5
*/
readonly evaluationPeriods?: number;
/**
* The number of data points that must be breaching to trigger the alarm.
*
* @default 5
*/
readonly datapointsToAlarm?: number;
/**
* The alarm name.
*
* @default - logicalId + ' - DatabaseMemoryUsagePercentage'
*/
readonly alarmName?: string;
/**
* The description of the alarm.
*
* @default - This alarm is used to detect high memory utilization of your cluster so that you can avoid failures when writing to
* your cluster. It is useful to know when you will need to scale up your cluster if your application does not expect to experience
* evictions.
*/
readonly alarmDescription?: string;
}
/**
* The properties for the ElastiCacheClusterDatabaseMemoryUsagePercentageAlarm construct.
*/
export interface ElastiCacheClusterDatabaseMemoryUsagePercentageAlarmProps extends ElastiCacheClusterAlarmProps, ElastiCacheDatabaseMemoryUsagePercentageAlarmConfig {
}
/**
* This alarm helps you monitor the memory utilization of your cluster.
*
* When your DatabaseMemoryUsagePercentage reaches 100%, the Redis OSS maxmemory policy is triggered and evictions might occur
* based on the policy selected. If no object in the cache matches the eviction policy, write operations fail. Some workloads
* expect or rely on evictions, but if not, you will need to increase the memory capacity of your cluster. You can scale your
* cluster out by adding more primary nodes, or scale it up by using a larger node type.
* Refer to {@link https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Scaling.html|Scaling ElastiCache for Redis OSS clusters} for details.
*
* The alarm is triggered when the percentage exceeds % threshold.
*/
export declare class ElastiCacheClusterDatabaseMemoryUsagePercentageAlarm extends cloudwatch.Alarm {
constructor(scope: IConstruct, id: string, props: ElastiCacheClusterDatabaseMemoryUsagePercentageAlarmProps);
}
/**
* The properties for the ElastiCacheReplicationGroupDatabaseMemoryUsagePercentageAlarm construct.
*/
export interface ElastiCacheReplicationGroupDatabaseMemoryUsagePercentageAlarmProps extends ElastiCacheReplicationGroupAlarmProps, ElastiCacheDatabaseMemoryUsagePercentageAlarmConfig {
}
/**
* This alarm helps you monitor the memory utilization of your cluster.
*
* When your DatabaseMemoryUsagePercentage reaches 100%, the Redis OSS maxmemory policy is triggered and evictions might occur
* based on the policy selected. If no object in the cache matches the eviction policy, write operations fail. Some workloads
* expect or rely on evictions, but if not, you will need to increase the memory capacity of your cluster. You can scale your
* cluster out by adding more primary nodes, or scale it up by using a larger node type.
* Refer to {@link https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Scaling.html|Scaling ElastiCache for Redis OSS clusters} for details.
*
* The alarm is triggered when the percentage exceeds % threshold.
*/
export declare class ElastiCacheReplicationGroupDatabaseMemoryUsagePercentageAlarm extends cloudwatch.Alarm {
constructor(scope: IConstruct, id: string, props: ElastiCacheReplicationGroupDatabaseMemoryUsagePercentageAlarmProps);
}
/**
* Configuration for the EngineCpuUtilization alarm.
*/
export interface ElastiCacheEngineCpuUtilizationAlarmConfig extends ElastiCacheAlarmBaseConfig {
/**
* Set the threshold to a percentage that reflects the critical engine CPU utilization level for your application.
* You can benchmark your cluster using your application and expected workload to correlate EngineCPUUtilization and
* performance as a reference, and then set the threshold accordingly. In most cases, you can set the threshold to
* about 90% of your available CPU.
*
* @default 90
*/
readonly threshold?: number;
/**
* The number of periods over which data is compared to the specified threshold.
*
* @default 5
*/
readonly evaluationPeriods?: number;
/**
* The number of data points that must be breaching to trigger the alarm.
*
* @default 5
*/
readonly datapointsToAlarm?: number;
/**
* The alarm name.
*
* @default - logicalId + ' - EngineCPUUtilization'
*/
readonly alarmName?: string;
/**
* The description of the alarm.
*
* @default - This alarm is used to detect high CPU utilization of the Redis OSS engine thread. It is useful if you want
* to monitor the CPU usage of the database engine itself.
*/
readonly alarmDescription?: string;
}
/**
* The properties for the ElastiCacheClusterEngineCpuUtilizationAlarm construct.
*/
export interface ElastiCacheClusterEngineCpuUtilizationAlarmProps extends ElastiCacheClusterAlarmProps, ElastiCacheEngineCpuUtilizationAlarmConfig {
}
/**
* This alarm helps to monitor the CPU utilization of a Redis OSS engine thread within the ElastiCache instance.
*
* Common reasons for high engine CPU are long-running commands that consume high CPU, a high number of requests, an increase of new
* client connection requests in a short time period, and high evictions when the cache doesn't have enough memory to hold new data.
* You should consider {@link https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Scaling.html|Scaling ElastiCache for Redis OSS clusters}
* by adding more nodes or scaling up your instance type.
*
* The alarm is triggered when the percentage exceeds the threshold.
*/
export declare class ElastiCacheClusterEngineCpuUtilizationAlarm extends cloudwatch.Alarm {
constructor(scope: IConstruct, id: string, props: ElastiCacheClusterEngineCpuUtilizationAlarmProps);
}
/**
* The properties for the ElastiCacheReplicationGroupEngineCpuUtilizationAlarm construct.
*/
export interface ElastiCacheReplicationGroupEngineCpuUtilizationAlarmProps extends ElastiCacheReplicationGroupAlarmProps, ElastiCacheEngineCpuUtilizationAlarmConfig {
}
/**
* This alarm helps to monitor the CPU utilization of a Redis OSS engine thread within the ElastiCache instance.
*
* Common reasons for high engine CPU are long-running commands that consume high CPU, a high number of requests, an increase of new
* client connection requests in a short time period, and high evictions when the cache doesn't have enough memory to hold new data.
* You should consider {@link https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Scaling.html|Scaling ElastiCache for Redis OSS clusters}
* by adding more nodes or scaling up your instance type.
*
* The alarm is triggered when the percentage exceeds the threshold.
*/
export declare class ElastiCacheReplicationGroupEngineCpuUtilizationAlarm extends cloudwatch.Alarm {
constructor(scope: IConstruct, id: string, props: ElastiCacheReplicationGroupEngineCpuUtilizationAlarmProps);
}
/**
* Configuration for the ReplicationLag alarm.
*/
export interface ElastiCacheReplicationLagAlarmConfig extends ElastiCacheAlarmBaseConfig {
/**
* Set the threshold according to your application's requirements and the potential impact of replication lag. You should
* consider your application's expected write rates and network conditions for the acceptable replication lag.
*/
readonly threshold: number;
/**
* The number of periods over which data is compared to the specified threshold.
*
* @default 15
*/
readonly evaluationPeriods?: number;
/**
* The number of data points that must be breaching to trigger the alarm.
*
* @default 15
*/
readonly datapointsToAlarm?: number;
/**
* The alarm name.
*
* @default - logicalId + ' - ReplicationLag'
*/
readonly alarmName?: string;
/**
* The description of the alarm.
*
* @default - This alarm is used to detect a delay between data updates on the primary node and their synchronization to replica node.
* It helps to ensure data consistency of a read replica cluster node.
*/
readonly alarmDescription?: string;
}
/**
* The properties for the ElastiCacheClusterReplicationLagAlarm construct.
*/
export interface ElastiCacheClusterReplicationLagAlarmProps extends ElastiCacheClusterAlarmProps, ElastiCacheReplicationLagAlarmConfig {
}
/**
* This alarm helps to monitor the replication health of your ElastiCache cluster.
*
* A high replication lag means that the primary node or the replica can't keep up the pace of the replication. If your write
* activity is too high, consider scaling your cluster out by adding more primary nodes, or scaling it up by using a larger node type.
* Refer to {@link https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Scaling.html|Scaling ElastiCache for Redis OSS clusters} for
* details. If your read replicas are overloaded by the amount of read requests,
* consider adding more read replicas.
*
* The alarm is triggered when the number of milliseconds exceeds the threshold.
*/
export declare class ElastiCacheClusterReplicationLagAlarm extends cloudwatch.Alarm {
constructor(scope: IConstruct, id: string, props: ElastiCacheClusterReplicationLagAlarmProps);
}
/**
* The properties for the ElastiCacheReplicationGroupReplicationLagAlarm construct.
*/
export interface ElastiCacheReplicationGroupReplicationLagAlarmProps extends ElastiCacheReplicationGroupAlarmProps, ElastiCacheReplicationLagAlarmConfig {
}
/**
* This alarm helps to monitor the replication health of your ElastiCache cluster.
*
* A high replication lag means that the primary node or the replica can't keep up the pace of the replication. If your write
* activity is too high, consider scaling your cluster out by adding more primary nodes, or scaling it up by using a larger node type.
* Refer to {@link https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Scaling.html|Scaling ElastiCache for Redis OSS clusters} for
* details. If your read replicas are overloaded by the amount of read requests,
* consider adding more read replicas.
*
* The alarm is triggered when the number of milliseconds exceeds the threshold.
*/
export declare class ElastiCacheReplicationGroupReplicationLagAlarm extends cloudwatch.Alarm {
constructor(scope: IConstruct, id: string, props: ElastiCacheReplicationGroupReplicationLagAlarmProps);
}
/**
* Configurations for the recommended alarms for an ElastiCache Service.
*
* Default actions are overridden by the actions specified in the
* individual alarm configurations.
*/
export interface ElastiCacheClusterRecommendedAlarmsConfig {
/**
* The default action to take when an alarm is triggered.
*
* @default - None
*/
readonly defaultAlarmAction?: cloudwatch.IAlarmAction;
/**
* The default action to take when an alarm enters the ok state.
*
* @default - None
*/
readonly defaultOkAction?: cloudwatch.IAlarmAction;
/**
* The default action to take when an alarm has insufficient data.
*
* @default - None
*/
readonly defaultInsufficientDataAction?: cloudwatch.IAlarmAction;
/**
* How to handle missing data for this alarm.
*
* @default TreatMissingData.MISSING
*/
readonly treatMissingData?: cloudwatch.TreatMissingData;
/**
* Alarm metrics to exclude from the recommended alarms.
*
* @default - None
*/
readonly excludeAlarms?: ElastiCacheRecommendedAlarmsMetrics[];
/**
* The resources to exclude from the recommended alarms.
*
* Use a resources id to exclude a specific resource.
*/
readonly excludeResources?: string[];
/**
* The configuration for the DatabaseMemoryUsagePercentage alarm.
*/
readonly configDatabaseMemoryUsagePercentageAlarm: ElastiCacheDatabaseMemoryUsagePercentageAlarmConfig;
/**
* The configuration for the EngineCpuUtilization alarm.
*/
readonly configEngineCpuUtilizationAlarm?: ElastiCacheEngineCpuUtilizationAlarmConfig;
/**
* The configuration for the ReplicationLag alarm.
*/
readonly configReplicationLagAlarm: ElastiCacheReplicationLagAlarmConfig;
}
/**
* Properties for the ElastiCacheClusterRecommendedAlarms construct.
*/
export interface ElastiCacheClusterRecommendedAlarmsProps extends ElastiCacheClusterRecommendedAlarmsConfig {
/**
* The ElastiCache CfnCacheCluster to monitor.
*/
readonly cacheCluster: elasticache.CfnCacheCluster;
}
/**
* A construct that creates the recommended alarms for an ElastiCache CfnCacheCluster.
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ElastiCache
*/
export declare class ElastiCacheClusterRecommendedAlarms extends Construct {
/**
* The DatabaseMemoryUsagePercentage alarm.
*/
readonly alarmDatabaseMemoryUsagePercentage?: ElastiCacheClusterDatabaseMemoryUsagePercentageAlarm;
/**
* The EngineCpuUtilization alarm.
*/
readonly alarmEngineCpuUtilization?: ElastiCacheClusterEngineCpuUtilizationAlarm;
/**
* The ReplicationLag alarm.
*/
readonly alarmReplicationLag?: ElastiCacheClusterReplicationLagAlarm;
constructor(scope: Construct, id: string, props: ElastiCacheClusterRecommendedAlarmsProps);
}
/**
* Configurations for the recommended alarms for an ElastiCache ReplicationGroup.
*
* Default actions are overridden by the actions specified in the
* individual alarm configurations.
*/
export interface ElastiCacheReplicationGroupRecommendedAlarmsConfig {
/**
* The default action to take when an alarm is triggered.
*
* @default - None
*/
readonly defaultAlarmAction?: cloudwatch.IAlarmAction;
/**
* The default action to take when an alarm enters the ok state.
*
* @default - None
*/
readonly defaultOkAction?: cloudwatch.IAlarmAction;
/**
* The default action to take when an alarm has insufficient data.
*
* @default - None
*/
readonly defaultInsufficientDataAction?: cloudwatch.IAlarmAction;
/**
* How to handle missing data for this alarm.
*
* @default TreatMissingData.MISSING
*/
readonly treatMissingData?: cloudwatch.TreatMissingData;
/**
* Alarm metrics to exclude from the recommended alarms.
*
* @default - None
*/
readonly excludeAlarms?: ElastiCacheRecommendedAlarmsMetrics[];
/**
* The resources to exclude from the recommended alarms.
*
* Use a resources id to exclude a specific resource.
*/
readonly excludeResources?: string[];
/**
* The configuration for the DatabaseMemoryUsagePercentage alarm.
*/
readonly configDatabaseMemoryUsagePercentageAlarm: ElastiCacheDatabaseMemoryUsagePercentageAlarmConfig;
/**
* The configuration for the EngineCPUUtilization alarm.
*/
readonly configEngineCpuUtilizationAlarm?: ElastiCacheEngineCpuUtilizationAlarmConfig;
/**
* The configuration for the ReplicationLag alarm.
*/
readonly configReplicationLagAlarm: ElastiCacheReplicationLagAlarmConfig;
}
/**
* Properties for the ElastiCacheReplicationGroupRecommendedAlarms construct.
*/
export interface ElastiCacheReplicationGroupRecommendedAlarmsProps extends ElastiCacheReplicationGroupRecommendedAlarmsConfig {
/**
* The ElastiCache CfnReplicationGroup to monitor.
*/
readonly cacheReplicationGroup: elasticache.CfnReplicationGroup;
}
/**
* A construct that creates the recommended alarms for an ElastiCache CfnReplicationGroup.
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ElastiCache
*/
export declare class ElastiCacheReplicationGroupRecommendedAlarms extends Construct {
/**
* The DatabaseMemoryUsagePercentage alarm.
*/
readonly alarmDatabaseMemoryUsagePercentage?: ElastiCacheReplicationGroupDatabaseMemoryUsagePercentageAlarm;
/**
* The EngineCpuUtilization alarm.
*/
readonly alarmEngineCpuUtilization?: ElastiCacheReplicationGroupEngineCpuUtilizationAlarm;
/**
* The ReplicationLag alarm.
*/
readonly alarmReplicationLag?: ElastiCacheReplicationGroupReplicationLagAlarm;
constructor(scope: Construct, id: string, props: ElastiCacheReplicationGroupRecommendedAlarmsProps);
}
/**
* An extension for the CfnCacheCluster construct that provides methods
* to create recommended alarms.
*/
export declare class CfnCacheCluster extends elasticache.CfnCacheCluster {
constructor(scope: Construct, id: string, props: elasticache.CfnCacheClusterProps);
/**
* Creates an alarm that monitors the DatabaseMemoryUsagePercentage for the ElastiCache cacheCluster.
*/
alarmDatabaseMemoryUsagePercentage(props: ElastiCacheDatabaseMemoryUsagePercentageAlarmConfig): ElastiCacheClusterDatabaseMemoryUsagePercentageAlarm;
/**
* Creates an alarm that monitors the EngineCpuUtilization for the ElastiCache cacheCluster.
*/
alarmEngineCpuUtilization(props?: ElastiCacheEngineCpuUtilizationAlarmConfig): ElastiCacheClusterEngineCpuUtilizationAlarm;
/**
* Creates an alarm that monitors the ReplicationLag for the ElastiCache cacheCluster.
*/
alarmReplicationLag(props: ElastiCacheReplicationLagAlarmConfig): ElastiCacheClusterReplicationLagAlarm;
/**
* Creates the recommended alarms for the ElastiCache CfnCacheCluster.
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ElastiCache
*/
applyRecommendedAlarms(props: ElastiCacheClusterRecommendedAlarmsConfig): ElastiCacheClusterRecommendedAlarms;
}
/**
* An extension for the CfnReplicationGroup construct that provides methods
* to create recommended alarms.
*/
export declare class CfnReplicationGroup extends elasticache.CfnReplicationGroup {
constructor(scope: Construct, id: string, props: elasticache.CfnReplicationGroupProps);
/**
* Creates an alarm that monitors the DatabaseMemoryUsagePercentage for the ElastiCache cacheReplicationGroup.
*/
alarmDatabaseMemoryUsagePercentage(props: ElastiCacheDatabaseMemoryUsagePercentageAlarmConfig): ElastiCacheReplicationGroupDatabaseMemoryUsagePercentageAlarm;
/**
* Creates an alarm that monitors the EngineCpuUtilization for the ElastiCache cacheReplicationGroup.
*/
alarmEngineCpuUtilization(props?: ElastiCacheEngineCpuUtilizationAlarmConfig): ElastiCacheReplicationGroupEngineCpuUtilizationAlarm;
/**
* Creates an alarm that monitors the ReplicationLag for the ElastiCache cacheReplicationGroup.
*/
alarmReplicationLag(props: ElastiCacheReplicationLagAlarmConfig): ElastiCacheReplicationGroupReplicationLagAlarm;
/**
* Creates the recommended alarms for the ElastiCache CfnReplicationGroup.
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ElastiCache
*/
applyRecommendedAlarms(props: ElastiCacheReplicationGroupRecommendedAlarmsConfig): ElastiCacheReplicationGroupRecommendedAlarms;
}
/**
* Configures the recommended alarms for an ElastiCache CfnCacheCluster
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ElastiCache
*/
export declare class ElastiCacheClusterRecommendedAlarmsAspect implements IAspect {
private readonly props;
constructor(props: ElastiCacheClusterRecommendedAlarmsConfig);
visit(node: IConstruct): void;
}
/**
* Configures the recommended alarms for an ElastiCache CfnReplicationGroup
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ElastiCache
*/
export declare class ElastiCacheReplicationGroupRecommendedAlarmsAspect implements IAspect {
private readonly props;
constructor(props: ElastiCacheReplicationGroupRecommendedAlarmsConfig);
visit(node: IConstruct): void;
}