Alarms and dashboards
This commit is contained in:
parent
1f5ef981fc
commit
2d03f9bf28
103
tf/cloudwatch.tf
103
tf/cloudwatch.tf
|
@ -1,3 +1,23 @@
|
||||||
|
resource "aws_cloudwatch_metric_alarm" "server_cpu" {
|
||||||
|
count = local.ami_available ? 1 : 0
|
||||||
|
|
||||||
|
alarm_name = "riju-server-cpu-high"
|
||||||
|
comparison_operator = "GreaterThanOrEqualToThreshold"
|
||||||
|
evaluation_periods = "5"
|
||||||
|
metric_name = "CPUUtilization"
|
||||||
|
namespace = "AWS/EC2"
|
||||||
|
period = "60"
|
||||||
|
statistic = "Maximum"
|
||||||
|
threshold = "80"
|
||||||
|
alarm_description = "CPU usage on Riju server is above 80%"
|
||||||
|
ok_actions = [aws_sns_topic.riju.arn]
|
||||||
|
alarm_actions = [aws_sns_topic.riju.arn]
|
||||||
|
insufficient_data_actions = [aws_sns_topic.riju.arn]
|
||||||
|
dimensions = {
|
||||||
|
AutoScalingGroupName = aws_autoscaling_group.server[count.index].name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resource "aws_cloudwatch_metric_alarm" "server_memory" {
|
resource "aws_cloudwatch_metric_alarm" "server_memory" {
|
||||||
count = local.ami_available ? 1 : 0
|
count = local.ami_available ? 1 : 0
|
||||||
|
|
||||||
|
@ -59,3 +79,86 @@ resource "aws_cloudwatch_metric_alarm" "server_root_volume_disk_space" {
|
||||||
path = "/"
|
path = "/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "aws_cloudwatch_dashboard" "riju" {
|
||||||
|
count = local.ami_available ? 1 : 0
|
||||||
|
|
||||||
|
dashboard_name = "Riju"
|
||||||
|
dashboard_body = <<EOF
|
||||||
|
{
|
||||||
|
"widgets": [
|
||||||
|
{
|
||||||
|
"type": "metric",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"width": 6,
|
||||||
|
"height": 6,
|
||||||
|
"properties": {
|
||||||
|
"title": "CPU",
|
||||||
|
"annotations": {
|
||||||
|
"alarms": [
|
||||||
|
"${aws_cloudwatch_metric_alarm.server_cpu[count.index].arn}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"view": "timeSeries",
|
||||||
|
"stacked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "metric",
|
||||||
|
"x": 12,
|
||||||
|
"y": 0,
|
||||||
|
"width": 6,
|
||||||
|
"height": 6,
|
||||||
|
"properties": {
|
||||||
|
"title": "Root volume disk space",
|
||||||
|
"annotations": {
|
||||||
|
"alarms": [
|
||||||
|
"${aws_cloudwatch_metric_alarm.server_root_volume_disk_space[count.index].arn}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"view": "timeSeries",
|
||||||
|
"stacked": false,
|
||||||
|
"type": "chart"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "metric",
|
||||||
|
"x": 18,
|
||||||
|
"y": 0,
|
||||||
|
"width": 6,
|
||||||
|
"height": 6,
|
||||||
|
"properties": {
|
||||||
|
"title": "Data volume disk space",
|
||||||
|
"annotations": {
|
||||||
|
"alarms": [
|
||||||
|
"${aws_cloudwatch_metric_alarm.server_data_volume_disk_space[count.index].arn}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"view": "timeSeries",
|
||||||
|
"stacked": false,
|
||||||
|
"type": "chart"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "metric",
|
||||||
|
"x": 6,
|
||||||
|
"y": 0,
|
||||||
|
"width": 6,
|
||||||
|
"height": 6,
|
||||||
|
"properties": {
|
||||||
|
"title": "Memory",
|
||||||
|
"annotations": {
|
||||||
|
"alarms": [
|
||||||
|
"${aws_cloudwatch_metric_alarm.server_memory[count.index].arn}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"view": "timeSeries",
|
||||||
|
"stacked": false,
|
||||||
|
"type": "chart"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue