Hi Team,
I am trying to create a cloud watch metric using the expressions and terraform, but getting Error: creating CloudWatch Metric Alarm ... ValidationError: Invalid metrics list
Below is the planned terraform code
resource "aws_cloudwatch_metric_alarm" "ec2-ebs-disk-high-avg-read-latency-alarm" {
+ actions_enabled = true
+ alarm_actions = [
+ "arn:aws:sns:us-west-1:672714205403:alarms-sns-topic",
]
+ alarm_description = "Alarm triggered when Avg read latency metric is greater than or equal to 1.5 s for a 3-minute period for webserver-new-1"
+ alarm_name = "ebs-disk-read-high-avg-read-latency-alarm"
+ arn = (known after apply)
+ comparison_operator = "GreaterThanOrEqualToThreshold"
+ evaluate_low_sample_count_percentiles = (known after apply)
+ evaluation_periods = 1
+ id = (known after apply)
+ ok_actions = [
+ "arn:aws:sns:us-west-1:672714205403:alarms-sns-topic",
]
+ tags_all = (known after apply)
+ threshold = 1500
+ treat_missing_data = "missing"
+ metric_query {
+ expression = "((m1 / m2) * 1000)"
+ id = "avg_read_latency"
+ return_data = true
}
+ metric_query {
+ expression = <<~EOT
SELECT SUM(VolumeReadOps)
FROM SCHEMA("AWS/EBS", VolumeId)
EOT
+ id = "m2"
+ period = 180
+ return_data = false
}
+ metric_query {
+ expression = <<~EOT
SELECT SUM(VolumeTotalWriteTime)
FROM SCHEMA("AWS/EBS", VolumeId)
EOT
+ id = "m1"
+ period = 180
+ return_data = false
}
}
Can you please help in figuring out the issue