Skip to content

Commit c1bb633

Browse files
Added CPU Alarm for the l1 and l2 nodes (#18)
1 parent 3138da8 commit c1bb633

9 files changed

Lines changed: 82 additions & 6 deletions

File tree

terraform/base_ec2_instance.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module "base_ec2_instance" {
1414
load_balancer = var.load_balancer
1515

1616
node = {
17+
alarm_cpu_threshold_percentage = var.base_node.alarm_cpu_threshold_percentage # 80
1718
alarm_memory_threshold_percentage = var.base_node.alarm_memory_threshold_percentage # 80
1819
alarm_disk_used_threshold_percentage = var.base_node.alarm_disk_used_threshold_percentage # 90
1920
ami_id = var.base_node.ami_id # "ami-0122205e4fe2524d5" # ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-arm64-server-20250821
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
resource "aws_cloudwatch_metric_alarm" "ethereum_ec2_cpu_high" {
2+
alarm_name = "${var.project}_${var.environment}_ethereum_ec2_cpu_high"
3+
alarm_description = "Watches for Ethereum EC2 CPU crossing high limit"
4+
5+
comparison_operator = "GreaterThanThreshold"
6+
evaluation_periods = "3"
7+
datapoints_to_alarm = 3
8+
9+
metric_name = "CPUUtilization"
10+
namespace = "AWS/EC2"
11+
period = "60"
12+
statistic = "Maximum"
13+
threshold = tostring(var.ethereum_node.alarm_cpu_threshold_percentage)
14+
15+
alarm_actions = [
16+
data.aws_sns_topic.developers_notifications.arn
17+
]
18+
ok_actions = [
19+
data.aws_sns_topic.developers_notifications.arn
20+
]
21+
22+
insufficient_data_actions = []
23+
24+
treat_missing_data = "notBreaching"
25+
26+
dimensions = {
27+
InstanceId = aws_instance.ethereum.id
28+
}
29+
30+
tags = {
31+
"Name" = "${var.project}_${var.environment}_ethereum_ec2_cpu_high"
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
resource "aws_cloudwatch_metric_alarm" "ec2_cpu_high" {
2+
alarm_name = "${var.project}_${var.environment}_${var.node_name}-ec2_cpu_high"
3+
alarm_description = "Watches for EC2 CPU crossing high limit"
4+
5+
comparison_operator = "GreaterThanThreshold"
6+
evaluation_periods = "3"
7+
datapoints_to_alarm = 3
8+
9+
metric_name = "CPUUtilization"
10+
namespace = "AWS/EC2"
11+
period = "60"
12+
statistic = "Maximum"
13+
threshold = tostring(var.node.alarm_cpu_threshold_percentage)
14+
15+
alarm_actions = [
16+
data.aws_sns_topic.developers_notifications.arn
17+
]
18+
ok_actions = [
19+
data.aws_sns_topic.developers_notifications.arn
20+
]
21+
22+
insufficient_data_actions = []
23+
24+
treat_missing_data = "notBreaching"
25+
26+
dimensions = {
27+
InstanceId = aws_instance.ec2_instance.id
28+
}
29+
30+
tags = {
31+
"Name" = "${var.project}_${var.environment}_${var.node_name}-ec2_cpu_high"
32+
}
33+
}

terraform/modules/l2_op_stack_chains/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ variable "region" {
3737

3838
variable "node" {
3939
type = object({
40+
alarm_cpu_threshold_percentage = number
4041
alarm_memory_threshold_percentage = number
4142
alarm_disk_used_threshold_percentage = number
4243
ami_id = string
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../ethereum_ec2_cpu_alarm.tf

terraform/production/terraform.tfvars

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
ethereum_node = {
2+
alarm_cpu_threshold_percentage = 80
23
alarm_memory_threshold_percentage = 90
34
alarm_disk_used_threshold_percentage = 90
45
ami_id = "ami-0122205e4fe2524d5" # ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-arm64-server-20250821
@@ -41,6 +42,7 @@ load_balancer = {
4142
}
4243

4344
base_node = {
45+
alarm_cpu_threshold_percentage = 80
4446
alarm_memory_threshold_percentage = 90
4547
alarm_disk_used_threshold_percentage = 90
4648
ami_id = "ami-0122205e4fe2524d5" # ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-arm64-server-20250821
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../ethereum_ec2_cpu_alarm.tf

terraform/staging/terraform.tfvars

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
ethereum_node = {
2+
alarm_cpu_threshold_percentage = 80
23
alarm_memory_threshold_percentage = 90
34
alarm_disk_used_threshold_percentage = 90
45
ami_id = "ami-0122205e4fe2524d5" # ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-arm64-server-20250821
@@ -8,9 +9,9 @@ ethereum_node = {
89
checkpoint_sync_url = "https://checkpoint-sync.sepolia.ethpandaops.io"
910
ebs_optimized = true
1011
ebs_volume = {
11-
size = 3072 # GB, 3TB
12-
type = "gp3"
13-
iops = 4000
12+
size = 3072 # GB, 3TB
13+
type = "gp3"
14+
iops = 4000
1415
throughput = 250
1516
}
1617
instance_type = "c7g.4xlarge"
@@ -41,6 +42,7 @@ load_balancer = {
4142
}
4243

4344
base_node = {
45+
alarm_cpu_threshold_percentage = 80
4446
alarm_memory_threshold_percentage = 90
4547
alarm_disk_used_threshold_percentage = 90
4648
ami_id = "ami-0122205e4fe2524d5" # ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-arm64-server-20250821

terraform/variables.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ variable "environment" {
3333

3434
variable "ethereum_node" {
3535
type = object({
36+
alarm_cpu_threshold_percentage = number
3637
alarm_memory_threshold_percentage = number
3738
alarm_disk_used_threshold_percentage = number
3839
ami_id = string
@@ -42,9 +43,9 @@ variable "ethereum_node" {
4243
checkpoint_sync_url = string
4344
ebs_optimized = bool
4445
ebs_volume = object({
45-
size = number
46-
type = string
47-
iops = number
46+
size = number
47+
type = string
48+
iops = number
4849
throughput = number
4950
})
5051
instance_type = string
@@ -108,6 +109,7 @@ variable "load_balancer" {
108109

109110
variable "base_node" {
110111
type = object({
112+
alarm_cpu_threshold_percentage = number
111113
alarm_memory_threshold_percentage = number
112114
alarm_disk_used_threshold_percentage = number
113115
ami_id = string

0 commit comments

Comments
 (0)