Skip to content

Commit 9ac9cdc

Browse files
author
James Healy
authored
Merge pull request #811 from buildkite/cloudwatch-agent
Replace awslogs with the cloudwatch-agent
2 parents 5f5c3f3 + 4a1f223 commit 9ac9cdc

File tree

12 files changed

+76
-77
lines changed

12 files changed

+76
-77
lines changed

goss.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ port:
3636
- '::'
3737

3838
service:
39-
awslogsd:
39+
amazon-cloudwatch-agent:
4040
enabled: true
4141
running: true
4242

packer/linux/buildkite-ami.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
},
4949
{
5050
"type": "shell",
51-
"script": "scripts/install-awslogs.sh"
51+
"script": "scripts/install-cloudwatch-agent.sh"
5252
},
5353
{
5454
"type": "shell",

packer/linux/conf/awslogs/awslogs.conf

Lines changed: 0 additions & 45 deletions
This file was deleted.

packer/linux/conf/bin/bk-install-elastic-stack.sh

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,6 @@ trap 'on_error $LINENO' ERR
3131
INSTANCE_ID=$(/opt/aws/bin/ec2-metadata --instance-id | cut -d " " -f 2)
3232
DOCKER_VERSION=$(docker --version | cut -f3 -d' ' | sed 's/,//')
3333

34-
# Cloudwatch logs needs a region specifically configured
35-
cat << EOF > /etc/awslogs/awscli.conf
36-
[plugins]
37-
cwlogs = cwlogs
38-
[default]
39-
region = $AWS_REGION
40-
EOF
41-
42-
systemctl enable awslogsd.service
43-
44-
# Start logging daemons as soon as possible to ensure failures in this script get sent
45-
systemctl restart rsyslog
46-
systemctl restart awslogsd
47-
4834
PLUGINS_ENABLED=()
4935
[[ $SECRETS_PLUGIN_ENABLED == "true" ]] && PLUGINS_ENABLED+=("secrets")
5036
[[ $ECR_PLUGIN_ENABLED == "true" ]] && PLUGINS_ENABLED+=("ecr")
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"agent": {
3+
"run_as_user": "root"
4+
},
5+
"logs": {
6+
"logs_collected": {
7+
"files": {
8+
"collect_list": [
9+
{
10+
"file_path": "/var/log/buildkite-agent",
11+
"log_group_name": "/buildkite/buildkite-agent",
12+
"log_stream_name": "{instance_id}",
13+
"timestamp_format": "%b %d %H:%M:%S"
14+
},
15+
{
16+
"file_path": "/var/log/cfn-init.log",
17+
"log_group_name": "/buildkite/cfn-init",
18+
"log_stream_name": "{instance_id}",
19+
"timestamp_format": "%Y-%m-%d %H:%M:%S,%f"
20+
},
21+
{
22+
"file_path": "/var/log/cloud-init.log",
23+
"log_group_name": "/buildkite/cloud-init",
24+
"log_stream_name": "{instance_id}",
25+
"timestamp_format": "%Y-%m-%d %H:%M:%S,%f"
26+
},
27+
{
28+
"file_path": "/var/log/cloud-init-output.log",
29+
"log_group_name": "/buildkite/cloud-init/output",
30+
"log_stream_name": "{instance_id}",
31+
"timestamp_format": "%Y-%m-%d %H:%M:%S,%f"
32+
},
33+
{
34+
"file_path": "/var/log/docker",
35+
"log_group_name": "/buildkite/docker-daemon",
36+
"log_stream_name": "{instance_id}",
37+
"timestamp_format": "%Y-%m-%dT%H:%M:%S.%f"
38+
},
39+
{
40+
"file_path": "/var/log/elastic-stack.log",
41+
"log_group_name": "/buildkite/elastic-stack",
42+
"log_stream_name": "{instance_id}",
43+
"timestamp_format": "%Y-%m-%d %H:%M:%S,%f"
44+
},
45+
{
46+
"file_path": "/var/log/messages",
47+
"log_group_name": "/buildkite/system",
48+
"log_stream_name": "{instance_id}",
49+
"timestamp_format": "%b %d %H:%M:%S"
50+
}
51+
]
52+
}
53+
}
54+
}
55+
}
File renamed without changes.
File renamed without changes.

packer/linux/scripts/install-awslogs.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -eu -o pipefail
4+
5+
6+
echo "Installing cloudwatch agent..."
7+
sudo yum install -y amazon-cloudwatch-agent
8+
9+
echo "Adding amazon-cloudwatch-agent config..."
10+
sudo cp /tmp/conf/cloudwatch-agent/config.json /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
11+
12+
echo "Configuring amazon-cloudwatch-agent to start at boot"
13+
sudo systemctl enable amazon-cloudwatch-agent
14+
15+
# These will send some systemctl service logs (like the buildkite agent and docker) to logfiles
16+
echo "Adding rsyslogd configs..."
17+
sudo cp /tmp/conf/cloudwatch-agent/rsyslog.d/* /etc/rsyslog.d/

packer/windows/buildkite-ami.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
},
4848
{
4949
"type": "powershell",
50-
"script": "scripts/install-awslogs.ps1"
50+
"script": "scripts/install-cloudwatch-agent.ps1"
5151
},
5252
{
5353
"type": "powershell",

0 commit comments

Comments
 (0)