Skip to content

Commit e68ba65

Browse files
Fix cloudwatch agent configuration (#11)
* Removed commas from json document * Fix the cloudwath agent configuration to send ssm logs too
1 parent c736eb3 commit e68ba65

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

terraform/ethereum_ssm_agent_configuration.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
resource "terraform_data" "copy_seelog_to_correct_position" {
1+
resource "terraform_data" "ssm_agent_log_configuration" {
22
depends_on = [
33
terraform_data.ethereum_ec2_install_reth
44
]
55

6+
triggers_replace = {
7+
seelog = sha1(file("${path.module}/../ssm-agent-seelog.xml"))
8+
}
9+
610
connection {
711
type = "ssh"
812
user = var.ethereum_node.user
@@ -21,6 +25,9 @@ resource "terraform_data" "copy_seelog_to_correct_position" {
2125
"sudo mkdir -p /etc/amazon/ssm",
2226
"sudo mv /home/${var.ethereum_node.user}/seelog.xml /etc/amazon/ssm/seelog.xml",
2327
"sudo chown root:root /etc/amazon/ssm/seelog.xml",
28+
"sudo chown -R root:adm /var/log/amazon",
29+
"sudo chmod 750 /var/log/amazon",
30+
"sudo chmod 750 /var/log/amazon/ssm",
2431
"sudo systemctl restart snap.amazon-ssm-agent.amazon-ssm-agent.service",
2532
]
2633
}

terraform/ssm-agent-seelog.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
<!--amazon-ssm-agent uses seelog logging -->
2-
<!--Seelog has github wiki pages, which contain detailed how-tos references: https://github.com/cihub/seelog/wiki -->
3-
<!--Seelog examples can be found here: https://github.com/cihub/seelog-examples -->
41
<seelog type="adaptive" mininterval="2000000" maxinterval="100000000" critmsgcount="500" minlevel="debug">
52
<exceptions>
63
<exception filepattern="test*" minlevel="error"/>
74
</exceptions>
8-
<outputs formatid="std:json-debug">
9-
<console formatid="std:json-debug"/>
5+
<outputs formatid="json">
6+
<console formatid="json"/>
107
<rollingfile type="size" filename="/var/log/amazon/ssm/amazon-ssm-agent.log" maxsize="30000000" maxrolls="5"/>
11-
<filter levels="error,critical" formatid="std:json-debug">
8+
<filter levels="error,critical" formatid="json">
129
<rollingfile type="size" filename="/var/log/amazon/ssm/errors.log" maxsize="10000000" maxrolls="5"/>
1310
</filter>
1411
</outputs>
12+
<formats>
13+
<format id="json" format='{"timestamp":"%Date(2006-01-02T15:04:05.000Z07:00)","level":"%LEVEL","funcShort":"%FuncShort","file":"%File","line":"%Line","message":"%Msg"}%n'/>
14+
</formats>
1515
</seelog>

terraform/templates/ethereum_ec2.amazon-cloudwatch-agent.json.tftpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"agent": {
33
"metrics_collection_interval": 60,
4-
"run_as_user": "cwagent"
4+
"run_as_user": "cwagent",
5+
"debug": true
56
},
67
"metrics": {
78
"namespace": "${namespace}",
@@ -115,7 +116,7 @@
115116
"log_group_name": "${ssm_agent_log_group_name}"
116117
},
117118
{
118-
"file_path": "/var/log/amazon/ssm/error.log",
119+
"file_path": "/var/log/amazon/ssm/errors.log",
119120
"log_group_name": "${ssm_agent_log_group_name_error}"
120121
}
121122
]

0 commit comments

Comments
 (0)