Alarm is on insufficient state for long time.
Graph of the metric:
This is the code that creates the alarm:
import boto3
# Create CloudWatch client
cloudwatch = boto3.client('cloudwatch')
# Create alarm
cloudwatch.put_metric_alarm(
AlarmName='Web_Server_CPU_Utilization',
ComparisonOperator='GreaterThanThreshold',
EvaluationPeriods=1,
MetricName='CPUUtilization',
Namespace='AWS/EC2',
Period=60,
Statistic='Average',
Threshold=70.0,
ActionsEnabled=False,
AlarmDescription='Alarm when server CPU exceeds 70%',
Dimensions=[
{
'Name': 'InstanceId',
'Value': 'INSTANCE_ID'
},
],
Unit='Seconds'
)
Also tried to create a metric alarm for Custom metrics, but this has different issue.
All the pre-defined metrics are in AWS namespaces
and custom metrics are in Custom namespaces
.
Tried giving Namespace='Custom/EC2'
, Namespace='EC2'
, Namespace='Custom/EC2'
,Namespace='AWS/EC2'
,Namespace='Custom/Custom'
.
But any of those cases. It is not pushing to the respected metric.