import * as cdk from "aws-cdk-lib"; import * as cloudwatch from "aws-cdk-lib/aws-cloudwatch"; import type * as lambda from "aws-cdk-lib/aws-lambda"; import * as logs from "aws-cdk-lib/aws-logs"; import * as constructs from "constructs"; export interface ServiceAlarmsProps extends cdk.StackProps { /** * The CloudWatch Alarm action to use for high-severity alarms. */ alarmAction: cloudwatch.IAlarmAction; /** * The CloudWatch Alarm action to use for warnings. */ warningAction: cloudwatch.IAlarmAction; /** * The name of the ECS service. */ serviceName: string; /** * Optional Lambda function that will receive forwarded log events. * If provided, subscription filters will be created to forward matching logs. */ logHandler?: lambda.IFunction; } /** * Various alarms and monitoring. * * By itself no alarms is created. Use the methods available * to add alarms. * * See SlackAlarm construct for SNS Action. */ export declare class ServiceAlarms extends constructs.Construct { private readonly alarmAction; private readonly warningAction; private readonly serviceName; private readonly logHandler?; constructor(scope: constructs.Construct, id: string, props: ServiceAlarmsProps); /** * For logs stored as JSON, monitor log entries logged * with level ERROR or higher, as well as any requests * that causes 500 for logging with liflig-logging. */ addJsonErrorAlarm(props: { logGroup: logs.ILogGroup; alarmDescription?: string; /** * Set to `true` to attach OK actions when the alarm returns to OK. * By default OK actions are NOT attached. * @default false */ enableOkAlarm?: boolean; /** * An action to use for CloudWatch alarm state changes instead of the default action */ action?: cloudwatch.IAlarmAction; }): void; addUncaughtJavaExceptionAlarm(props: { logGroup: logs.ILogGroup; alarmDescription?: string; /** * @default false */ enabled?: boolean; enableOkAlarm?: boolean; action?: cloudwatch.IAlarmAction; }): void; /** * Sets up CloudWatch alarms for monitoring an ECS service behind a target group: * 1) one that triggers if the target is responding with too many 5xx errors (aggregate 5xx count). * 2) one that triggers if the 95% percentile of response times from the target is too high. * 3) one that triggers if there are no healthy targets or if the load balancer fails to connect to targets. * 4) a single5xxResponseAlarm which triggers on a single 5xx response from a target. */ addTargetGroupAlarms(props: { /** * The full name of the target group. */ targetGroupFullName: string; /** * The full name of the application load balancer. */ loadBalancerFullName: string; /** * Configuration for a composite alarm. * * @default Configured with sane defaults. */ targetHealthAlarm?: { /** * @default true */ enabled?: boolean; /** * Whether to attach OK actions for this alarm. @default true */ enableOkAlarm?: boolean; /** * An action to use for CloudWatch alarm state changes instead of the default action */ action?: cloudwatch.IAlarmAction; /** * @default 60 seconds */ period?: cdk.Duration; /** * @default 1 */ evaluationPeriods?: number; /** * @default 1 */ threshold?: number; description?: string; }; /** * Configuration for an alarm. * * @default Configured with sane defaults. */ tooMany5xxResponsesFromTargetsAlarm?: { /** * @default true */ enabled?: boolean; /** * Whether to attach OK actions for this alarm. @default true */ enableOkAlarm?: boolean; /** * An action to use for CloudWatch alarm state changes instead of the default action */ action?: cloudwatch.IAlarmAction; /** * @default 60 seconds */ period?: cdk.Duration; /** * @default 3 */ evaluationPeriods?: number; /** * @default 10 */ threshold?: number; description?: string; }; /** * Configuration for an alarm. * * @default Configured with sane defaults. */ targetResponseTimeAlarm?: { /** * @default true */ enabled?: boolean; /** * Whether to attach OK actions for this alarm. @default true */ enableOkAlarm?: boolean; /** * An action to use for CloudWatch alarm state changes instead of the default action */ action?: cloudwatch.IAlarmAction; /** * @default 5 minutes */ period?: cdk.Duration; /** * @default 1 */ evaluationPeriods?: number; /** * @default 1s */ threshold?: cdk.Duration; description?: string; }; /** * Configuration for an alarm. * * @default Configured with sane defaults. */ single5xxResponseAlarm?: { /** * @default true */ enabled?: boolean; /** * Whether to attach OK actions for this alarm. @default true */ enableOkAlarm?: boolean; /** * An action to use for CloudWatch alarm state changes instead of the default action */ action?: cloudwatch.IAlarmAction; /** * @default 60 seconds */ period?: cdk.Duration; /** * @default 1 */ evaluationPeriods?: number; /** * @default 1 */ threshold?: number; description?: string; }; }): void; }