3

I am creating cloudwatch alarms in cdk typescript package. Most of the metrics are also created from the cloudwatch metrics.

const functionErrors = new cloudwatch.Metric({
     namespace: 'AWS/Lambda',
     metricName: 'ConcurrentExecutions',
     period: cdk.Duration.minutes(5),
     statistic: 'Maximum',
     dimensions: {
        FunctionName: myFunction.functionName,
     },
});

And creating alarms on that using:

  new cloudwatch.Alarm(this, 'lambda-errors-alarm', {
         metric: functionErrors,
         threshold: 1,
         comparisonOperator:
         cloudwatch.ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
         evaluationPeriods: 1,
         alarmDescription:
             'Alarm if the SUM of Errors is greater than or equal to the threshold 
             (1) for 1 evaluation period',
  });

But now I want to create alarms on metrics which are in cloudwatch, but are not created throught the same cdk package, rather created by some other service package, in same aws account.

Is there a way in which we can refer to the cloudwatch metric from cdk package, then create alarm for that? Also I would like to add the metric in cloudwatch dashboard, but there is no metric object reference as it is not created by same ckd package, but rather by service package.

0 Answers0