@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.
260 lines (259 loc) • 9.67 kB
TypeScript
import { IAspect, aws_efs as efs, aws_cloudwatch as cloudwatch, Duration } from 'aws-cdk-lib';
import { Construct, IConstruct } from 'constructs';
import { AlarmBaseProps } from './common';
/**
* The recommended metrics for EFS alarms.
*/
export declare enum EfsRecommendedAlarmsMetrics {
/**
* Percentage of how close a file system is to reaching the I/O limit of the General Purpose
* performance mode.
*/
PERCENT_IO_LIMIT = "PercentIOLimit",
/**
* The number of burst credits that a file system has. Burst credits allow a file system to burst
* to throughput levels above a file system's baseline level for periods of time.
*/
BURST_CREDIT_BALANCE = "BurstCreditBalance"
}
/**
* The common optional configuration for the alarms.
*/
export interface EfsAlarmBaseConfig extends AlarmBaseProps {
/**
* The period over which the specified statistic is applied.
*
* @default Duration.minutes(1)
*/
readonly period?: Duration;
}
/**
* The common properties for the EFS FileSystem alarms.
*/
export interface EfsFileSystemAlarmProps {
/**
* The EFS FileSystem to monitor.
*/
readonly fileSystem: efs.FileSystem;
}
/**
* Configuration for the PercentIOLimit alarm.
*/
export interface EfsPercentIOLimitAlarmConfig extends EfsAlarmBaseConfig {
/**
* When the file system reaches its I/O limit, it may respond to read and write requests slower.
* Therefore, it is recommended that the metric is monitored to avoid impacting applications that
* use the file system. The threshold can be set around 100%. However, this value can be adjusted
* to a lower value based on file system characteristics.
*
* @default 100
*/
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 - fileSystemId + ' - PercentIOLimit'
*/
readonly alarmName?: string;
/**
* The description of the alarm.
*
* @default - This alarm is used to detect how close the file system is to reach the I/O limit of the General
* Purpose performance mode. Consistent high I/O percentage can be an indicator of the file system cannot scale
* with respect to I/O requests enough and the file system can be a resource bottleneck for the applications
* that use the file system.
*/
readonly alarmDescription?: string;
}
/**
* The properties for the EfsFileSystemPercentIOLimitAlarm construct.
*/
export interface EfsFileSystemPercentIOLimitAlarmProps extends EfsFileSystemAlarmProps, EfsPercentIOLimitAlarmConfig {
}
/**
* This alarm helps in ensuring that the workload stays within the I/O limit available to the file system.
*
* If the metric reaches its I/O limit consistently, consider moving the application to a file system that
* uses Max I/O performance as mode. For troubleshooting, check clients that are connected to the file system
* and applications of the clients that throttles the file system.
*
* The alarm is triggered when the percentage exceed or equals % threshold.
*/
export declare class EfsFileSystemPercentIOLimitAlarm extends cloudwatch.Alarm {
constructor(scope: IConstruct, id: string, props: EfsFileSystemPercentIOLimitAlarmProps);
}
/**
* Configuration for the BurstCreditBalance alarm.
*/
export interface EfsBurstCreditBalanceAlarmConfig extends EfsAlarmBaseConfig {
/**
* When the file system run out of burst credits and even if the baseline throughput rate is lower,
* EFS continues to provide a metered throughput of 1 MiBps to all file systems. However, it is recommended
* that the metric is monitored for low burst credit balance to avoid the file system acting as resource
* bottleneck for the applications. The threshold can be set around 0 bytes.
*
* @default 0
*/
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 - fileSystemId + ' - BurstCreditBalance'
*/
readonly alarmName?: string;
/**
* The description of the alarm.
*
* @default - This alarm is used to detect low burst credit balance of the file system. Consistent low
* burst credit balance can be an indicator of the slowing down in throughput and increase in I/O latency.
*/
readonly alarmDescription?: string;
}
/**
* The properties for the EfsFileSystemBurstCreditBalanceAlarm construct.
*/
export interface EfsFileSystemBurstCreditBalanceAlarmProps extends EfsFileSystemAlarmProps, EfsBurstCreditBalanceAlarmConfig {
}
/**
* This alarm helps in ensuring that there is available burst credit balance for the file system usage.
*
* When there is no available burst credit, applications access to the the file system will be limited due to low throughput.
* If the metric drops to 0 consistently, consider changing the throughput mode to Elastic or Provisioned throughput mode.
*
* The alarm is triggered when the percentage is lower or equals the threshold.
*/
export declare class EfsFileSystemBurstCreditBalanceAlarm extends cloudwatch.Alarm {
constructor(scope: IConstruct, id: string, props: EfsFileSystemBurstCreditBalanceAlarmProps);
}
/**
* Configurations for the recommended alarms for an EFS Service.
*
* Default actions are overridden by the actions specified in the
* individual alarm configurations.
*/
export interface EfsFileSystemRecommendedAlarmsConfig {
/**
* 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?: EfsRecommendedAlarmsMetrics[];
/**
* The resources to exclude from the recommended alarms.
*
* Use a resources id to exclude a specific resource.
*/
readonly excludeResources?: string[];
/**
* The configuration for the PercentIOLimit alarm.
*/
readonly configPercentIOLimitAlarm?: EfsPercentIOLimitAlarmConfig;
/**
* The configuration for the BurstCreditBalance alarm.
*/
readonly configBurstCreditBalanceAlarm?: EfsBurstCreditBalanceAlarmConfig;
}
/**
* Properties for the EfsFileSystemRecommendedAlarms construct.
*/
export interface EfsFileSystemRecommendedAlarmsProps extends EfsFileSystemRecommendedAlarmsConfig {
/**
* The EFS FileSystem to monitor.
*/
readonly fileSystem: efs.FileSystem;
}
/**
* A construct that creates the recommended alarms for an EFS FileSystem.
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#EFS
*/
export declare class EfsFileSystemRecommendedAlarms extends Construct {
/**
* The PercentIOLimit alarm.
*/
readonly alarmPercentIOLimit?: EfsFileSystemPercentIOLimitAlarm;
/**
* The BurstCreditBalance alarm.
*/
readonly alarmBurstCreditBalance?: EfsFileSystemBurstCreditBalanceAlarm;
constructor(scope: Construct, id: string, props: EfsFileSystemRecommendedAlarmsProps);
}
/**
* An extension for the FileSystem construct that provides methods
* to create recommended alarms.
*/
export declare class FileSystem extends efs.FileSystem {
constructor(scope: Construct, id: string, props: efs.FileSystemProps);
/**
* Creates an alarm that monitors the PercentIOLimit for the EFS fileSystem.
*/
alarmPercentIOLimit(props?: EfsPercentIOLimitAlarmConfig): EfsFileSystemPercentIOLimitAlarm;
/**
* Creates an alarm that monitors the BurstCreditBalance for the EFS fileSystem.
*/
alarmBurstCreditBalance(props?: EfsBurstCreditBalanceAlarmConfig): EfsFileSystemBurstCreditBalanceAlarm;
/**
* Creates the recommended alarms for the EFS FileSystem.
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#EFS
*/
applyRecommendedAlarms(props?: EfsFileSystemRecommendedAlarmsConfig): EfsFileSystemRecommendedAlarms;
}
/**
* Configures the recommended alarms for an EFS FileSystem.
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#EFS
*/
export declare class EfsRecommendedAlarmsAspect implements IAspect {
private readonly props?;
constructor(props?: EfsFileSystemRecommendedAlarmsConfig | undefined);
visit(node: IConstruct): void;
}