What is the correct approach to extract data from the cloudwatch agent json file
below to create a terraform
cloudwatch alarm
and send it to SNS
as notification.
cloudwatch agent json file
name of the file cloudwatchagent.json
{"metrics": {"metrics_collected": {"disk": {"measurement": ["used_percent", # this is the data i need to extract ],"metrics_collection_interval": 60,"resources": ["*" ] }, } }}
cloudwatch terraform configuration
resource "aws_cloudwatch_metric_alarm""disk-space" { alarm_name = "web-disk-space" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metric_name = "???" # not sure what to use here since `used_percent` data are in the json file namespace = "AWS/EC2" period = "120" statistic = "Average" threshold = "1" alarm_description = "This metric send an alarm to avoid running out of disk space" alarm_actions = [ "${aws_sns_topic.alarm.arn}" ] dimensions { InstanceId = "${aws_instance.foo.id}" # send the data to aws SNS }}