import * as cloudfront from 'aws-cdk-lib/aws-cloudfront'; import * as docdb from 'aws-cdk-lib/aws-docdb'; import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'; import * as ecs from 'aws-cdk-lib/aws-ecs'; import * as elbv2 from 'aws-cdk-lib/aws-elasticloadbalancingv2'; import * as lambda from 'aws-cdk-lib/aws-lambda'; import * as rds from 'aws-cdk-lib/aws-rds'; import * as sns from 'aws-cdk-lib/aws-sns'; import { Construct, IConstruct } from 'constructs'; import { LogAlarmProps, MetricAlarmProps, MonitorType, WatchApplicationLoadBalancerOptions, WatchApplicationTargetGroupOptions, WatchCloudfrontDistributionOptions, WatchDatabaseClusterOptions, WatchDocDbClusterOptions, WatchDynamoDbTableOptions, WatchEcsServiceOptions, WatchLambdaFunctionOptions } from './'; /** * Interface for Watchful implementation. */ export interface IWatchful extends IConstruct { /** * Adds and alert for error logs * @param scope - The construct to add the alarm to * @param id - The name of the service * @param alarm - The alarm properties see {@link LogAlarmProps} */ createLogAlarm(scope: Construct, id: MonitorType, alarm: LogAlarmProps): void; /** * Adds the alarmTopic as alarm action to the given alarm. * @param scope - The construct to add the alarm to * @param id - The id of the alarm * @param alarm - Additional options for the watch see {@link MetricAlarmProps} * */ createAlarm(scope: Construct, id: MonitorType, alarm: MetricAlarmProps): void; } export interface OverrideAlarmThresholdProps { /** * The scope of the resource for which the threshold needs to be overriden */ readonly monitoredResourceScope: Construct; /** * Id of the monitor that needs to be overriden. * Eg - Errors, Thresholds, LogErrorMonitor */ readonly monitorType: MonitorType; /** * The threshold that needs to be set */ readonly threshold: number; } export interface ShouldOverrideThresholdProps { readonly watchfulMonitorScope: Construct; readonly watchfulNodeId: string; } export interface ShouldOverrideThresholdReturnProps { readonly shouldOverrideThreshold: boolean; readonly threshold?: number; } export declare abstract class AbstractWatchful extends Construct implements IWatchful { protected readonly metricsAlarmOverrides: Array; abstract createLogAlarm(scope: Construct, id: MonitorType, alarm: LogAlarmProps): void; abstract createAlarm(scope: Construct, id: MonitorType, alarm: MetricAlarmProps): void; /** * Override the default thresholds for the watchful monitors */ overrideAlarmThreshold(props: OverrideAlarmThresholdProps): void; protected shouldOverrideThreshold(props: ShouldOverrideThresholdProps): ShouldOverrideThresholdReturnProps; /** * Adds alarms for the given lambda function. * @param fn - A lambda function that should be watched [disable-awslint:ref-via-interface] * @param options - Additional options for the watch see {@link WatchLambdaFunctionOptions} */ watchLambdaFunction(fn: lambda.Function, options?: WatchLambdaFunctionOptions): void; /** * Adds alarms for the given Cloudfront Distribution. * @param cf - A Cloudfront Distribution that should be watched [disable-awslint:ref-via-interface] * @param options - Additional options for the watch see {@link WatchCloudfrontDistributionOptions} */ watchCloudfrontDistribution(cf: cloudfront.Distribution, options?: WatchCloudfrontDistributionOptions): void; /** * Adds alarms for the given ECS service. * @param service - An ECS service that should be watched [disable-awslint:ref-via-interface] * @param options - Additional options for the watch see {@link WatchEcsServiceOptions} */ watchEcsService(service: ecs.BaseService, options?: WatchEcsServiceOptions): void; /** * Adds alarms for the given application load balancer. * @param alb - An application load balancer that should be watched [disable-awslint:ref-via-interface] * @param options - Additional options for the watch see {@link WatchApplicationLoadBalancerOptions} */ watchAlb(alb: elbv2.ApplicationLoadBalancer, options?: WatchApplicationLoadBalancerOptions): void; /** * Adds alarms for the given application target gorup. * @param atg - An application target group that should be watched [disable-awslint:ref-via-interface] * @param options - Additional options for the watch see {@link WatchApplicationTargetGroupOptions} */ watchApplicationTargetGroup(atg: elbv2.ApplicationTargetGroup, options?: WatchApplicationTargetGroupOptions): void; /** * Adds alarms for the given DocDb cluster. * @param docDb - An DocDb cluster that should be watched [disable-awslint:ref-via-interface] * @param options - Additional options for the watch see {@link WatchDocDbClusterOptions} */ watchDocDb(docDb: docdb.DatabaseCluster, options?: WatchDocDbClusterOptions): void; /** * Adds alarms for the given database cluster. * @param databaseCluster - An database cluster that should be watched [disable-awslint:ref-via-interface] * @param options - Additional options for the watch see {@link WatchDatabaseClusterOptions} */ watchDatabaseCluster(databaseCluster: rds.DatabaseCluster, options?: WatchDatabaseClusterOptions): void; /** * Adds alarms for the given DynamoDb table. * @param dynamoDbTable - An database cluster that should be watched [disable-awslint:ref-via-interface] * @param options - Additional options for the watch see {@link WatchDynamoDbTableOptions} */ watchDynamoDbTable(dynamoDbTable: dynamodb.Table | dynamodb.TableV2, options?: WatchDynamoDbTableOptions): void; } /** * Properties for defining Watchful */ export interface WatchfulProps { /** * An SNS topic as target for alarm actions. * * @defaultValue The SNS topic provided by OpsGenie Integration account module. */ readonly alarmSns?: sns.ITopic; /** * The service token for the DataDog Monitor custom resource. * * @defaultValue Empty. */ readonly dataDogMonitorServiceToken?: string; /** * The service name. * * @defaultValue The stack name. */ readonly dataDogMonitorServiceName?: string; /** * The OpsGenie handle used in DataDog to forward the DD monitor to OpsGenie. * * @defaultValue Empty if dataDogMonitorServiceToken is not set. Otherwise, team SSM parameter from LandingZone is used. */ readonly dataDogOpsGenieIntegrationName?: string; } /** * A construct to watch given scope or resources. Opinionated DataDog alarms are automatically created for watched resources. * @deprecated Please use watchfulv2 instead */ export declare class Watchful extends AbstractWatchful { private readonly alarmTopic?; private readonly dataDogMonitorServiceToken?; private readonly dataDogOpsGenieIntegrationName?; private readonly dataDogMonitorServiceName; constructor(scope: Construct, id: string, props?: WatchfulProps); /** * Adds the alarmTopic as alarm action to the given alarm. * @param scope - The construct to add the alarm to * @param id - The id of the alarm * @param alarm - Additional options for the watch see {@link MetricAlarmProps} */ createAlarm(scope: Construct, id: MonitorType, alarm: MetricAlarmProps): void; /** * Adds an alert for error logs * @param scope - The construct to add the alarm to * @param id - The id of the alarm * @param alarm - The alarm properties see {@link LogAlarmProps} */ createLogAlarm(scope: Construct, id: MonitorType, alarm: LogAlarmProps): void; /** * Watches the given scope and adds alarms for known resources. */ watchScope(scope: Construct): void; }