@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.
180 lines (179 loc) • 6.52 kB
TypeScript
import { IAspect, aws_autoscaling as autoscaling, aws_cloudwatch as cloudwatch, Duration } from 'aws-cdk-lib';
import { Construct, IConstruct } from 'constructs';
import { AlarmBaseProps } from './common';
/**
* The recommended metrics for EC2 AutoScaling alarms.
*/
export declare enum AutoScalingRecommendedAlarmsMetrics {
/**
* The number of capacity units that are running as part of the Auto Scaling group.
*/
GROUP_IN_SERVICE_CAPACITY = "GroupInServiceCapacity"
}
/**
* The common optional configuration for the alarms.
*/
export interface AutoScalingAlarmBaseConfig extends AlarmBaseProps {
/**
* The period over which the specified statistic is applied.
*
* @default Duration.minutes(1)
*/
readonly period?: Duration;
}
/**
* The common properties for the EC2 AutoScalingGroup alarms.
*/
export interface AutoScalingGroupAlarmProps {
/**
* The EC2 AutoScalingGroup to monitor.
*/
readonly autoScalingGroup: autoscaling.AutoScalingGroup;
}
/**
* Configuration for the GroupInServiceCapacity alarm.
*/
export interface AutoScalingGroupInServiceCapacityAlarmConfig extends AutoScalingAlarmBaseConfig {
/**
* The threshold value should be the minimum capacity required to run your workload. In most cases,
* you can set this to match the GroupDesiredCapacity metric.
*/
readonly threshold: number;
/**
* The number of periods over which data is compared to the specified threshold.
*
* @default 10
*/
readonly evaluationPeriods?: number;
/**
* The number of data points that must be breaching to trigger the alarm.
*
* @default 10
*/
readonly datapointsToAlarm?: number;
/**
* The alarm name.
*
* @default - autoScalingGroupName + ' - GroupInServiceCapacity'
*/
readonly alarmName?: string;
/**
* The description of the alarm.
*
* @default - This alarm can detect a low availability in your auto scaling group because of launch failures
* or suspended launches.
*/
readonly alarmDescription?: string;
}
/**
* The properties for the AutoScalingGroupGroupInServiceCapacityAlarm construct.
*/
export interface AutoScalingGroupGroupInServiceCapacityAlarmProps extends AutoScalingGroupAlarmProps, AutoScalingGroupInServiceCapacityAlarmConfig {
}
/**
* This alarm helps to detect when the capacity in the group is below the desired capacity required for your workload.
*
* To troubleshoot, check your scaling activities for launch failures and confirm that your desired capacity configuration
* is correct.
*
* The alarm is triggered when the capacity in the group is less than threshold.
*/
export declare class AutoScalingGroupGroupInServiceCapacityAlarm extends cloudwatch.Alarm {
constructor(scope: IConstruct, id: string, props: AutoScalingGroupGroupInServiceCapacityAlarmProps);
}
/**
* Configurations for the recommended alarms for an EC2 AutoScalingGroup.
*
* Default actions are overridden by the actions specified in the
* individual alarm configurations.
*/
export interface AutoScalingGroupRecommendedAlarmsConfig {
/**
* 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?: AutoScalingRecommendedAlarmsMetrics[];
/**
* The resources to exclude from the recommended alarms.
*
* Use a resources id to exclude a specific resource.
*/
readonly excludeResources?: string[];
/**
* The configuration for the GroupInServiceCapacity alarm.
*/
readonly configGroupInServiceCapacityAlarm: AutoScalingGroupInServiceCapacityAlarmConfig;
}
/**
* Properties for the AutoScalingGroupRecommendedAlarms construct.
*/
export interface AutoScalingGroupRecommendedAlarmsProps extends AutoScalingGroupRecommendedAlarmsConfig {
/**
* The EC2 AutoScalingGroup to monitor.
*/
readonly autoScalingGroup: autoscaling.AutoScalingGroup;
}
/**
* A construct that creates the recommended alarms for an EC2 AutoScalingGroup.
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#AutoScaling
*/
export declare class AutoScalingGroupRecommendedAlarms extends Construct {
/**
* The GroupInServiceCapacity alarm.
*/
readonly alarmGroupInServiceCapacity?: AutoScalingGroupGroupInServiceCapacityAlarm;
constructor(scope: Construct, id: string, props: AutoScalingGroupRecommendedAlarmsProps);
}
/**
* An extension for the AutoScalingGroup construct that provides methods
* to create recommended alarms.
*/
export declare class AutoScalingGroup extends autoscaling.AutoScalingGroup {
constructor(scope: Construct, id: string, props: autoscaling.AutoScalingGroupProps);
/**
* Creates an alarm that monitors the GroupInServiceCapacity for the EC2 autoScalingGroup.
*/
alarmGroupInServiceCapacity(props: AutoScalingGroupInServiceCapacityAlarmConfig): AutoScalingGroupGroupInServiceCapacityAlarm;
/**
* Creates the recommended alarms for the EC2 AutoScalingGroup.
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#AutoScaling
*/
applyRecommendedAlarms(props: AutoScalingGroupRecommendedAlarmsConfig): AutoScalingGroupRecommendedAlarms;
}
/**
* Configures the recommended alarms for an EC2 AutoScalingGroup.
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#AutoScaling
*/
export declare class AutoScalingRecommendedAlarmsAspect implements IAspect {
private readonly props;
constructor(props: AutoScalingGroupRecommendedAlarmsConfig);
visit(node: IConstruct): void;
}