Prevent double logging when restarting CloudWatch agent

0

As part of our ebextensions, we restart the CloudWatch agent to add new configuration to it. As a result, this can sometimes push the last few minutes of logs to CloudWatch again, such as the eb-engine.log. This results in CloudWatch having duplicated log events with mismatched timestamps, while the actual log file on the EC2 instance contains only one log event.

This image shows two instances producing four log entries, the latter two with the same "actual" timestamp. Duplicate logs

Are there any steps we can take to prevent this from happening?

2 Answers
1

Thank you for reaching out to us. To assist you better, we need some confidential I.e.non-public information from you. The best way to share this information is by creating a support case with AWS from the AWS account where the issue occurred. You can do this by following this link

AWS
SUPPORT ENGINEER
answered a month ago
profile pictureAWS
EXPERT
iBehr
reviewed a month ago
0

Did you stop the CloudWatch agent and then start it or just restart?

profile pictureAWS
EXPERT
iBehr
answered a month ago
  • Restarted via the amazon-cloudwatch-agent-ctl command, in full:

    sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a append-config -m ec2 -c file:our_new_config.json -s

    The -s argument being the restart flag.