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.

247 lines (246 loc) 8.82 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 NetworkTargetGroup alarms. */ export declare enum NetworkTargetGroupRecommendedAlarmsMetrics { /** * The number of healthy targets in the target group. */ HEALTHY_HOST_COUNT = "HealthyHostCount", /** * The number of unhealthy targets in the target group. */ UNHEALTHY_HOST_COUNT = "UnHealthyHostCount" } /** * The common optional configuration for the alarms. */ export interface NetworkTargetGroupAlarmBaseConfig extends AlarmBaseProps { /** * The period over which the specified statistic is applied. * * @default Duration.minutes(1) */ readonly period?: Duration; } /** * The common properties for the NetworkTargetGroup alarms. */ export interface NetworkTargetGroupAlarmProps { /** * The NetworkTargetGroup to monitor. */ readonly targetGroup: elbv2.NetworkTargetGroup; } /** * Configuration for the HealthyHostCount alarm. */ export interface NetworkTargetGroupHealthyHostCountAlarmConfig extends NetworkTargetGroupAlarmBaseConfig { /** * The value against which the specified statistic is compared. * You should set this threshold based on the minimum number of healthy hosts * required for your application to function properly. * * @default 1 */ 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 - targetGroupName + ' - HealthyHostCount' */ readonly alarmName?: string; /** * The description of the alarm. * * @default - This alarm is used to detect when the number of healthy hosts in the target group * falls below the threshold. A low number of healthy hosts can indicate service availability issues. */ readonly alarmDescription?: string; } /** * The properties for the NetworkTargetGroupHealthyHostCountAlarm construct. */ export interface NetworkTargetGroupHealthyHostCountAlarmProps extends NetworkTargetGroupAlarmProps, NetworkTargetGroupHealthyHostCountAlarmConfig { } /** * This alarm is used to detect when the number of healthy hosts in the target group falls below the threshold. * * A low number of healthy hosts can indicate service availability issues. */ export declare class NetworkTargetGroupHealthyHostCountAlarm extends cloudwatch.Alarm { constructor(scope: IConstruct, id: string, props: NetworkTargetGroupHealthyHostCountAlarmProps); } /** * Configuration for the UnHealthyHostCount alarm. */ export interface NetworkTargetGroupUnHealthyHostCountAlarmConfig extends NetworkTargetGroupAlarmBaseConfig { /** * The value against which the specified statistic is compared. * You should set this threshold based on the maximum number of unhealthy hosts * that your application can tolerate before service is impacted. * * @default 0 */ 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 - targetGroupName + ' - UnHealthyHostCount' */ readonly alarmName?: string; /** * The description of the alarm. * * @default - This alarm is used to detect when the number of unhealthy hosts in the target group * exceeds the threshold. A high number of unhealthy hosts can indicate service health issues. */ readonly alarmDescription?: string; } /** * The properties for the NetworkTargetGroupUnHealthyHostCountAlarm construct. */ export interface NetworkTargetGroupUnHealthyHostCountAlarmProps extends NetworkTargetGroupAlarmProps, NetworkTargetGroupUnHealthyHostCountAlarmConfig { } /** * This alarm is used to detect when the number of unhealthy hosts in the target group exceeds the threshold. * * A high number of unhealthy hosts can indicate service health issues. */ export declare class NetworkTargetGroupUnHealthyHostCountAlarm extends cloudwatch.Alarm { constructor(scope: IConstruct, id: string, props: NetworkTargetGroupUnHealthyHostCountAlarmProps); } /** * Configurations for the recommended alarms for a NetworkTargetGroup. * * Default actions are overridden by the actions specified in the * individual alarm configurations. */ export interface NetworkTargetGroupRecommendedAlarmsConfig { /** * 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?: NetworkTargetGroupRecommendedAlarmsMetrics[]; /** * The resources to exclude from the recommended alarms. * * Use a resources id to exclude a specific resource. */ readonly excludeResources?: string[]; /** * The configuration for the HealthyHostCount alarm. */ readonly configHealthyHostCountAlarm?: NetworkTargetGroupHealthyHostCountAlarmConfig; /** * The configuration for the UnHealthyHostCount alarm. */ readonly configUnHealthyHostCountAlarm?: NetworkTargetGroupUnHealthyHostCountAlarmConfig; } /** * Properties for the NetworkTargetGroupRecommendedAlarms construct. */ export interface NetworkTargetGroupRecommendedAlarmsProps extends NetworkTargetGroupRecommendedAlarmsConfig { /** * The NetworkTargetGroup to monitor. */ readonly targetGroup: elbv2.NetworkTargetGroup; } /** * A construct that creates the recommended alarms for a NetworkTargetGroup. * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/elb-metricscollected.html */ export declare class NetworkTargetGroupRecommendedAlarms extends Construct { /** * The HealthyHostCount alarm. */ readonly alarmHealthyHostCount?: NetworkTargetGroupHealthyHostCountAlarm; /** * The UnHealthyHostCount alarm. */ readonly alarmUnHealthyHostCount?: NetworkTargetGroupUnHealthyHostCountAlarm; constructor(scope: Construct, id: string, props: NetworkTargetGroupRecommendedAlarmsProps); } /** * An extension for the NetworkTargetGroup construct that provides methods * to create recommended alarms. */ export declare class NetworkTargetGroup extends elbv2.NetworkTargetGroup { constructor(scope: Construct, id: string, props: elbv2.NetworkTargetGroupProps); /** * Creates an alarm that monitors the healthy host count for the NetworkTargetGroup. */ alarmHealthyHostCount(props?: NetworkTargetGroupHealthyHostCountAlarmConfig): NetworkTargetGroupHealthyHostCountAlarm; /** * Creates an alarm that monitors the unhealthy host count for the NetworkTargetGroup. */ alarmUnHealthyHostCount(props?: NetworkTargetGroupUnHealthyHostCountAlarmConfig): NetworkTargetGroupUnHealthyHostCountAlarm; /** * Creates the recommended alarms for the NetworkTargetGroup. * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/elb-metricscollected.html */ applyRecommendedAlarms(props: NetworkTargetGroupRecommendedAlarmsConfig): NetworkTargetGroupRecommendedAlarms; } /** * Configures the recommended alarms for a NetworkTargetGroup. * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/elb-metricscollected.html */ export declare class NetworkTargetGroupRecommendedAlarmsAspect implements IAspect { private readonly props; constructor(props: NetworkTargetGroupRecommendedAlarmsConfig); visit(node: IConstruct): void; }