CloudWatch metric provides several metrics for Lambda functions such as:
We will create a new metric that sums up the number of hits to DynamoDB that fail
client_cloudwatch = boto3.client('cloudwatch')
        client_cloudwatch.put_metric_data(
            Namespace='BooksList_Lambda',
            MetricData=[
                {
                    'MetricName': 'FailedConnectToDynamoDB',
                    'Dimensions': [
                        {
                            'Name': 'env',
                            'Value': 'staging'
                        },
                    ],
                    'Value': 1.0,
                    'Unit': 'Seconds'
                },
            ]
        )



{
    "Sid": "VisualEditor0",
    "Effect": "Allow",
    "Action": "cloudwatch:PutMetricData",
    "Resourse": "*"
},





So we have created a custom metric. Next step we will use it to create a CloudWatch Alarm