Skip to content

Commit 848e32f

Browse files
celo cloudwatch agent configuration
1 parent 890a1ed commit 848e32f

6 files changed

Lines changed: 176 additions & 1 deletion

terraform/celo-configs/scripts/start-healthcheck.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
if [ "$HEALTH_CHECK_ENABLED" = "true" ]; then
4-
npm run start
4+
exec npm run start
55
else
66
echo "Healthcheck is disabled, exiting..."
77
exit 0
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
resource "local_file" "celo_ec2_install_cloudwatch_agent" {
2+
content = local.celo_cloudwatch_agent_configuration_content
3+
filename = "${path.module}/generated-${local.celo_cloudwatch_agent_configuration_file}"
4+
}
5+
6+
resource "terraform_data" "celo_ec2_cloudwatch_agent_configuration_update" {
7+
depends_on = [
8+
aws_instance.celo_ec2_instance,
9+
aws_eip.celo,
10+
module.celo_ec2_install_cloudwatch_agent,
11+
local_file.celo_ec2_install_cloudwatch_agent
12+
]
13+
14+
triggers_replace = {
15+
celo_cloudwatch_agent_configuration = sha1(local_file.celo_ec2_install_cloudwatch_agent.content)
16+
}
17+
18+
connection {
19+
type = "ssh"
20+
user = var.celo_node.user
21+
port = var.celo_node.ssh_port
22+
host = aws_eip.celo.public_ip
23+
private_key = file("${path.module}/ethereum.pem")
24+
}
25+
26+
provisioner "file" {
27+
source = local_file.celo_ec2_install_cloudwatch_agent.filename
28+
destination = "/home/${var.celo_node.user}/${local.celo_cloudwatch_agent_configuration_file}"
29+
}
30+
31+
provisioner "remote-exec" {
32+
inline = [
33+
"sudo mv /home/${var.celo_node.user}/${local.celo_cloudwatch_agent_configuration_file} /opt/aws/amazon-cloudwatch-agent/etc/${local.celo_cloudwatch_agent_configuration_file}",
34+
"sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/${local.celo_cloudwatch_agent_configuration_file} -s",
35+
"sudo systemctl restart amazon-cloudwatch-agent"
36+
]
37+
}
38+
}

terraform/locals.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,15 @@ locals {
101101
eigenda_local_s3_bucket = var.celo_node.eigenda_local_s3_bucket
102102
})
103103

104+
celo_cloudwatch_agent_configuration_file = "celo_ec2.amazon-cloudwatch-agent.json"
105+
celo_cloudwatch_agent_configuration_content = templatefile("${local.templates_folder}/${local.celo_cloudwatch_agent_configuration_file}.tftpl", {
106+
chain = var.celo_node.chain
107+
namespace = local.cloudwatch_namespace
108+
nginx_log_group_name_access = module.celo_nginx_configuration.cloudwatch_log_group_nginx_access_name
109+
nginx_log_group_name_error = module.celo_nginx_configuration.cloudwatch_log_group_nginx_error_name
110+
ssm_agent_log_group_name = module.celo_ssm_agent_cloudwatch.cloudwatch_log_group_ssm_agent_name
111+
ssm_agent_log_group_name_error = module.celo_ssm_agent_cloudwatch.cloudwatch_log_group_ssm_agent_error_name
112+
})
113+
104114
// ----
105115
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../celo_ec2_cloudwatch_agent_configuration_update.tf
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../celo_ec2_cloudwatch_agent_configuration_update.tf
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{
2+
"agent": {
3+
"metrics_collection_interval": 60,
4+
"run_as_user": "cwagent",
5+
"debug": true
6+
},
7+
"metrics": {
8+
"namespace": "${namespace}",
9+
"append_dimensions": {
10+
"InstanceId": "$${aws:InstanceId}",
11+
"InstanceType": "$${aws:InstanceType}"
12+
},
13+
"metrics_collected": {
14+
"cpu": {
15+
"measurement": [
16+
"cpu_usage_idle",
17+
"cpu_usage_iowait",
18+
"cpu_usage_user",
19+
"cpu_usage_system",
20+
"cpu_usage_steal",
21+
"cpu_usage_nice",
22+
"cpu_usage_softirq",
23+
"cpu_usage_irq"
24+
],
25+
"totalcpu": true
26+
},
27+
"disk": {
28+
"measurement": [
29+
"used_percent"
30+
],
31+
"resources": [
32+
"/",
33+
"/data"
34+
],
35+
"dimensions": [
36+
[
37+
"path"
38+
]
39+
]
40+
},
41+
"mem": {
42+
"measurement": [
43+
"mem_used_percent"
44+
]
45+
},
46+
"procstat": [
47+
{
48+
"pattern": "docker",
49+
"measurement": [
50+
"cpu_usage",
51+
"memory_rss"
52+
]
53+
},
54+
{
55+
"pattern": "replica-healthcheck",
56+
"measurement": [
57+
"cpu_usage",
58+
"memory_rss"
59+
]
60+
},
61+
{
62+
"pattern": "geth",
63+
"measurement": [
64+
"cpu_usage",
65+
"memory_rss"
66+
]
67+
},
68+
{
69+
"pattern": "eigenda-proxy",
70+
"measurement": [
71+
"cpu_usage",
72+
"memory_rss"
73+
]
74+
},
75+
{
76+
"pattern": "op-node",
77+
"measurement": [
78+
"cpu_usage",
79+
"memory_rss"
80+
]
81+
},
82+
{
83+
"pattern": "prometheus",
84+
"measurement": [
85+
"cpu_usage",
86+
"memory_rss"
87+
]
88+
},
89+
{
90+
"pattern": "grafana",
91+
"measurement": [
92+
"cpu_usage",
93+
"memory_rss"
94+
]
95+
}
96+
]
97+
}
98+
},
99+
"logs": {
100+
"logs_collected": {
101+
"files": {
102+
"collect_list": [
103+
{
104+
"file_path": "/var/log/nginx/access.log",
105+
"log_group_name": "${nginx_log_group_name_access}",
106+
"timestamp_format": "[%d/%b/%Y:%H:%M:%S %z]"
107+
},
108+
{
109+
"file_path": "/var/log/nginx/error.log",
110+
"log_group_name": "${nginx_log_group_name_error}",
111+
"timestamp_format": "%Y/%m/%d %H:%M:%S"
112+
},
113+
{
114+
"file_path": "/var/log/amazon/ssm/amazon-ssm-agent.log",
115+
"log_group_name": "${ssm_agent_log_group_name}"
116+
},
117+
{
118+
"file_path": "/var/log/amazon/ssm/errors.log",
119+
"log_group_name": "${ssm_agent_log_group_name_error}"
120+
}
121+
]
122+
}
123+
}
124+
}
125+
}

0 commit comments

Comments
 (0)