I'm trying to use CloudWatch embedded metrics format (emf) inside a beanstalk environment running Docker image.
(Documentation on emf here and here )
To be able to emit emf metrics, the aws-cloudwatch-agent needs to have the following configuration:
{
"logs": {
"metrics_collected": {
"emf": { }
}
}
}
However I'm not able to find the namespace definition to pass emf configuration to beanstalk, using the .ebextensions
method described here.
The available namespaces seem to just stream the existing logs.
How can I enable CloudWatch emf publishing in an elastic beanstalk environment?
To pass additional configuration use platform hooks described in this question. More detail on platform hooks: AWS documentation,
.platform/hooks/predeploy/emf-config.sh
with content:#!/bin/bash
echo '{
"logs": {
"metrics_collected": {
"emf": { }
}
}
}' > "/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/emf_metrics.json"
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a append-config
(...)
artifacts: {
files: [
"Dockerrun.aws.json",
".platform/hooks/**/*"
]
},
chmod +x path/to/emf-config.sh
git update-index --chmod=+x path/to/emf-config.sh