Skip to content

Instantly share code, notes, and snippets.

@Warrenn
Created April 27, 2022 15:50
Show Gist options
  • Save Warrenn/eec46f440990fe928ef6944cb4876282 to your computer and use it in GitHub Desktop.
Save Warrenn/eec46f440990fe928ef6944cb4876282 to your computer and use it in GitHub Desktop.
cat <<'EOF' > /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent-schema.tmpl
{
"agent": {
"run_as_user": "root"
},
"logs": {
"logs_collected": {
"files": {
"collect_list": [
{
"file_path": "${!IBEAM_GATEWAY_DIR}/logs/gw.*.log",
"log_group_name": "auto-invest-gateway-log",
"log_stream_name": "gateway-{instance_id}"
},
{
"file_path": "${!OUTPUTS_DIR}/*",
"log_group_name": "auto-invest-gateway-log",
"log_stream_name": "outputs-{instance_id}"
}
]
}
}
}
}
EOF
IBEAM_GATEWAY_DIR=$IBEAM_GATEWAY_DIR OUTPUTS_DIR=$OUTPUTS_DIR envsubst < /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent-schema.tmpl > /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent-schema.json
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent-schema.json
systemctl restart amazon-cloudwatch-agent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment