1

I have below code for setting up alarm for AWS glue job using CDK:

import { aws_cloudwatch as cloudwatch, aws_events as events } from 'aws-cdk-lib';

// jobName. This is our AWS Glue script to monitor
const jobFailedRule = new Rule(scope, '{DVRD replication} JobFailureRule', {
  eventPattern: {
    source: ['aws.glue'],
    detailType: ['Glue Job State Change'],
    detail: {
      state: ['FAILED', 'TIMEOUT', 'ERROR'],
      jobName: [DVRD replication],
    },
  },
})

//cloudwatch metric
const numFailedJobsMetric = new cloudwatch.Metric({
  namespace: 'AWS/Events',
  metricName: 'TriggeredRules',
  statistic: 'Sum',
  dimensionsMap: {
   RuleName: jobFailedRule.ruleName,
  },
})

//cloudwatch alarm
const numFailedJobsAlarm = new cloudwatch.Alarm(scope, '{DVRD replication} numFailedJobsAlarm', {
  metric: numFailedJobsMetric,
  threshold: 1,
  evaluationPeriods: 1,
});

Now i want to setup SNS email notification for this alarm but not sure how to do it.

4
  • Create an SNS Topic, then add it as an alarm action to the cloudwatch alarm. Add a subscription to the topic for your email address. confirm subscription email. Commented Aug 20, 2024 at 16:47
  • do you have any example? Commented Aug 21, 2024 at 7:07
  • example here : medium.com/@ureniucbogdan/… Commented Aug 21, 2024 at 8:30
  • the problem is i dont know how to use SnsAction and assigned this with alarm.. Commented Aug 22, 2024 at 6:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.