UNPKG

@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.

387 lines (386 loc) 14.8 kB
import { IAspect, aws_elasticloadbalancingv2 as elbv2, aws_cloudwatch as cloudwatch, Duration } from 'aws-cdk-lib'; import { Construct, IConstruct } from 'constructs'; import { AlarmBaseProps } from './common'; /** * The recommended metrics for ApplicationLoadBalancer alarms. */ export declare enum ApplicationLoadBalancerRecommendedAlarmsMetrics { /** * The number of connection requests that were rejected because the load balancer had reached its maximum connections. */ REJECTED_CONNECTION_COUNT = "RejectedConnectionCount", /** * The number of HTTP 4XX client error codes generated by the load balancer. */ HTTP_CODE_ELB_4XX_COUNT = "HTTPCode_ELB_4XX_Count", /** * The number of HTTP 5XX server error codes generated by the load balancer. */ HTTP_CODE_ELB_5XX_COUNT = "HTTPCode_ELB_5XX_Count", /** * The number of HTTP 5XX server error codes generated by the targets. */ HTTP_CODE_TARGET_5XX_COUNT = "HTTPCode_Target_5XX_Count" } /** * The common optional configuration for the alarms. */ export interface ApplicationLoadBalancerAlarmBaseConfig extends AlarmBaseProps { /** * The period over which the specified statistic is applied. * * @default Duration.minutes(1) */ readonly period?: Duration; } /** * The common properties for the ApplicationLoadBalancer alarms. */ export interface ApplicationLoadBalancerAlarmProps { /** * The ApplicationLoadBalancer to monitor. */ readonly loadBalancer: elbv2.ApplicationLoadBalancer; } /** * Configuration for the RejectedConnectionCount alarm. */ export interface ApplicationLoadBalancerRejectedConnectionCountAlarmConfig extends ApplicationLoadBalancerAlarmBaseConfig { /** * The value against which the specified statistic is compared. * You should set this threshold based on the acceptable number of rejected connections. * * @default 0 */ readonly threshold?: number; /** * The number of periods over which data is compared to the specified threshold. * * @default 3 */ readonly evaluationPeriods?: number; /** * The number of data points that must be breaching to trigger the alarm. * * @default 3 */ readonly datapointsToAlarm?: number; /** * The alarm name. * * @default - loadBalancerName + ' - RejectedConnectionCount' */ readonly alarmName?: string; /** * The description of the alarm. * * @default - This alarm is used to detect when the load balancer is rejecting connections. * Rejected connections can indicate that the load balancer has reached its maximum connection limit. */ readonly alarmDescription?: string; } /** * The properties for the ApplicationLoadBalancerRejectedConnectionCountAlarm construct. */ export interface ApplicationLoadBalancerRejectedConnectionCountAlarmProps extends ApplicationLoadBalancerAlarmProps, ApplicationLoadBalancerRejectedConnectionCountAlarmConfig { } /** * This alarm is used to detect when the load balancer is rejecting connections. * * Rejected connections can indicate that the load balancer has reached its maximum connection limit. * * The alarm is triggered when the number of rejected connections is greater than threshold. */ export declare class ApplicationLoadBalancerRejectedConnectionCountAlarm extends cloudwatch.Alarm { constructor(scope: IConstruct, id: string, props: ApplicationLoadBalancerRejectedConnectionCountAlarmProps); } /** * Configuration for the HTTPCode_ELB_4XX_Count alarm. */ export interface ApplicationLoadBalancerHttpCode4xxCountAlarmConfig extends ApplicationLoadBalancerAlarmBaseConfig { /** * The number of periods over which data is compared to the specified threshold. * * @default 3 */ readonly evaluationPeriods?: number; /** * The number of data points that must be breaching to trigger the alarm. * * @default 3 */ readonly datapointsToAlarm?: number; /** * The width of the anomaly detection band, expressed as a number of standard deviations from the metric's mean. * * @default 8 */ readonly stdDevs?: number; /** * The alarm name. * * @default - loadBalancerName + ' - HTTPCode_ELB_4XX_Count' */ readonly alarmName?: string; /** * The description of the alarm. * * @default - This alarm is used to detect when the load balancer is generating 4XX errors. * A high number of 4XX errors can indicate client-side issues or misconfigured requests. */ readonly alarmDescription?: string; } /** * The properties for the ApplicationLoadBalancerHttpCode4xxCountAlarm construct. */ export interface ApplicationLoadBalancerHttpCode4xxCountAlarmProps extends ApplicationLoadBalancerAlarmProps, ApplicationLoadBalancerHttpCode4xxCountAlarmConfig { } /** * This anomaly detection alarm is used to detect when the load balancer is generating * unusually many 4XX errors. * * A high number of 4XX errors can indicate client-side issues or misconfigured requests. * * The alarm is triggered when the number of 4XX errors is outside the upper threshold * of the anomaly detection band. */ export declare class ApplicationLoadBalancerHttpCode4xxCountAlarm extends cloudwatch.AnomalyDetectionAlarm { constructor(scope: IConstruct, id: string, props: ApplicationLoadBalancerHttpCode4xxCountAlarmProps); } /** * Configuration for the HTTPCode_ELB_5XX_Count alarm. */ export interface ApplicationLoadBalancerHttpCode5xxCountAlarmConfig extends ApplicationLoadBalancerAlarmBaseConfig { /** * The number of periods over which data is compared to the specified threshold. * * @default 3 */ readonly evaluationPeriods?: number; /** * The number of data points that must be breaching to trigger the alarm. * * @default 3 */ readonly datapointsToAlarm?: number; /** * The alarm name. * * @default - loadBalancerName + ' - HTTPCode_ELB_5XX_Count' */ readonly alarmName?: string; /** * The width of the anomaly detection band, expressed as a number of standard deviations from the metric's mean. * * @default 8 */ readonly stdDevs?: number; /** * The description of the alarm. * * @default - This alarm is used to detect when the load balancer is generating 5XX errors. * A high number of 5XX errors can indicate issues with the load balancer itself. */ readonly alarmDescription?: string; } /** * The properties for the ApplicationLoadBalancerHttpCode5xxCountAlarm construct. */ export interface ApplicationLoadBalancerHttpCode5xxCountAlarmProps extends ApplicationLoadBalancerAlarmProps, ApplicationLoadBalancerHttpCode5xxCountAlarmConfig { } /** * This anomaly detection alarm is used to detect when the load balancer is generating * unusually many 5XX errors. * * A high number of 5XX errors can indicate issues with the load balancer itself. * * The alarm is triggered when the number of 5XX errors is outside the upper threshold * of the anomaly detection band. */ export declare class ApplicationLoadBalancerHttpCode5xxCountAlarm extends cloudwatch.AnomalyDetectionAlarm { constructor(scope: IConstruct, id: string, props: ApplicationLoadBalancerHttpCode5xxCountAlarmProps); } /** * Configuration for the HTTPCode_Target_5XX_Count alarm. */ export interface ApplicationLoadBalancerHttpCodeTarget5xxCountAlarmConfig extends ApplicationLoadBalancerAlarmBaseConfig { /** * The value against which the specified statistic is compared. * You should set this threshold based on the acceptable number of 5XX errors from targets. * * @default 0 */ readonly threshold?: number; /** * The number of periods over which data is compared to the specified threshold. * * @default 3 */ readonly evaluationPeriods?: number; /** * The number of data points that must be breaching to trigger the alarm. * * @default 3 */ readonly datapointsToAlarm?: number; /** * The alarm name. * * @default - loadBalancerName + ' - HTTPCode_Target_5XX_Count' */ readonly alarmName?: string; /** * The description of the alarm. * * @default - This alarm is used to detect when the targets are generating 5XX errors. * A high number of 5XX errors can indicate issues with the application or backend services. */ readonly alarmDescription?: string; } /** * The properties for the ApplicationLoadBalancerHttpCodeTarget5xxCountAlarm construct. */ export interface ApplicationLoadBalancerHttpCodeTarget5xxCountAlarmProps extends ApplicationLoadBalancerAlarmProps, ApplicationLoadBalancerHttpCodeTarget5xxCountAlarmConfig { } /** * This alarm is used to detect when the targets are generating 5XX errors. * * A high number of 5XX errors can indicate issues with the application or backend services. * * The alarm is triggered when the number of 5XX errors from targets is greater than threshold. */ export declare class ApplicationLoadBalancerHttpCodeTarget5xxCountAlarm extends cloudwatch.Alarm { constructor(scope: IConstruct, id: string, props: ApplicationLoadBalancerHttpCodeTarget5xxCountAlarmProps); } /** * Configurations for the recommended alarms for an ApplicationLoadBalancer. * * Default actions are overridden by the actions specified in the * individual alarm configurations. */ export interface ApplicationLoadBalancerRecommendedAlarmsConfig { /** * 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?: ApplicationLoadBalancerRecommendedAlarmsMetrics[]; /** * The resources to exclude from the recommended alarms. * * Use a resources id to exclude a specific resource. */ readonly excludeResources?: string[]; /** * The configuration for the RejectedConnectionCount alarm. */ readonly configRejectedConnectionCountAlarm?: ApplicationLoadBalancerRejectedConnectionCountAlarmConfig; /** * The configuration for the HTTPCode_ELB_4XX_Count alarm. */ readonly configHttpCode4xxCountAlarm?: ApplicationLoadBalancerHttpCode4xxCountAlarmConfig; /** * The configuration for the HTTPCode_ELB_5XX_Count alarm. */ readonly configHttpCode5xxCountAlarm?: ApplicationLoadBalancerHttpCode5xxCountAlarmConfig; /** * The configuration for the HTTPCode_Target_5XX_Count alarm. */ readonly configHttpCodeTarget5xxCountAlarm?: ApplicationLoadBalancerHttpCodeTarget5xxCountAlarmConfig; } /** * Properties for the ApplicationLoadBalancerRecommendedAlarms construct. */ export interface ApplicationLoadBalancerRecommendedAlarmsProps extends ApplicationLoadBalancerRecommendedAlarmsConfig { /** * The ApplicationLoadBalancer to monitor. */ readonly loadBalancer: elbv2.ApplicationLoadBalancer; } /** * A construct that creates the recommended alarms for an ApplicationLoadBalancer. * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/elb-metricscollected.html */ export declare class ApplicationLoadBalancerRecommendedAlarms extends Construct { /** * The RejectedConnectionCount alarm. */ readonly alarmRejectedConnectionCount?: ApplicationLoadBalancerRejectedConnectionCountAlarm; /** * The HTTPCode_ELB_4XX_Count alarm. */ readonly alarmHttpCode4xxCount?: ApplicationLoadBalancerHttpCode4xxCountAlarm; /** * The HTTPCode_ELB_5XX_Count alarm. */ readonly alarmHttpCode5xxCount?: ApplicationLoadBalancerHttpCode5xxCountAlarm; /** * The HTTPCode_Target_5XX_Count alarm. */ readonly alarmHttpCodeTarget5xxCount?: ApplicationLoadBalancerHttpCodeTarget5xxCountAlarm; constructor(scope: Construct, id: string, props: ApplicationLoadBalancerRecommendedAlarmsProps); } /** * An extension for the ApplicationLoadBalancer construct that provides methods * to create recommended alarms. */ export declare class ApplicationLoadBalancer extends elbv2.ApplicationLoadBalancer { constructor(scope: Construct, id: string, props: elbv2.ApplicationLoadBalancerProps); /** * Creates an alarm that monitors the rejected connection count for the ApplicationLoadBalancer. */ alarmRejectedConnectionCount(props?: ApplicationLoadBalancerRejectedConnectionCountAlarmConfig): ApplicationLoadBalancerRejectedConnectionCountAlarm; /** * Creates an alarm that monitors the HTTP 4XX error count for the ApplicationLoadBalancer. */ alarmHttpCode4xxCount(props?: ApplicationLoadBalancerHttpCode4xxCountAlarmConfig): ApplicationLoadBalancerHttpCode4xxCountAlarm; /** * Creates an alarm that monitors the HTTP 5XX error count for the ApplicationLoadBalancer. */ alarmHttpCode5xxCount(props?: ApplicationLoadBalancerHttpCode5xxCountAlarmConfig): ApplicationLoadBalancerHttpCode5xxCountAlarm; /** * Creates an alarm that monitors the HTTP 5XX error count from targets for the ApplicationLoadBalancer. */ alarmHttpCodeTarget5xxCount(props?: ApplicationLoadBalancerHttpCodeTarget5xxCountAlarmConfig): ApplicationLoadBalancerHttpCodeTarget5xxCountAlarm; /** * Creates the recommended alarms for the ApplicationLoadBalancer. * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/elb-metricscollected.html */ applyRecommendedAlarms(props: ApplicationLoadBalancerRecommendedAlarmsConfig): ApplicationLoadBalancerRecommendedAlarms; } /** * Configures the recommended alarms for an ApplicationLoadBalancer. * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/elb-metricscollected.html */ export declare class ApplicationLoadBalancerRecommendedAlarmsAspect implements IAspect { private readonly props; constructor(props: ApplicationLoadBalancerRecommendedAlarmsConfig); visit(node: IConstruct): void; }