Can CloudWatch alarm be integrated with Amplify application using AWS CDK.

0

I have an amplify application created using AWS Console. I wanted to integrate the CloudWatch alarms to amplify using AWS CDK (Java)

2개 답변
0
수락된 답변

great !! It worked, Thanks.

The below is the code that creates a Amazon CloudWatch alarm for existing Amplify application.

import software.amazon.awscdk.services.cloudwatch.CfnAlarm;

CloudWatch Alarm for Amplify Errors

    CfnAlarm amplifyErrorAlarm = CfnAlarm.Builder.create(this, "AmplifyErrorAlarm")

            .alarmName("AmplifyErrorAlarm")

            .comparisonOperator("GreaterThanThreshold")

            .evaluationPeriods(1)

            .threshold(1.0)  // Set the appropriate threshold for your case

            .metricName("Requests")  // Replace with the actual metric name

            .namespace("AWS/AmplifyHosting")    // Replace with the actual namespace for Amplify metrics

            .period(300)  // 5 minutes (300 seconds)

            .statistic("Sum")

            .actionsEnabled(true)

            .alarmActions(List.of("ARN-OF-THE-SNS-TOPIC"))  // Replace with your SNS topic ARN

            .dimensions(List.of(

                    CfnAlarm.DimensionProperty.builder()

                            .name("App")

                            .value("abcd123")  // Replace with your Amplify application ID

                            .build()

            ))

            .alarmDescription("Amplify Error Alarm")

            .build();
답변함 3달 전
0

Hi, when you create an application with Amplify, it sends metrics to CloudWatch. The list of preset metrics is indicated in the Amplify documentation.

You can create CloudWatch alarms programmatically using the CDK, cli or CloudFormation for example. The CDK construct simply needs you to build a metric object that will specify which metric you want to monitor (for example namespace: AWS/AmplifyHosting, name: Requests…) and pass it as a parameter to the Alarm object that you create with the comparison operator, threshold, evaluation period and actions.

profile pictureAWS
Jsc
답변함 4달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠