I have a mongodb log file in an EC2 instance and I would like to send the logs to AWS cloud watch.
The file is at the default location of a linux AMI : /var/log/mongodb/mongodb.log
What do I have to do send these logs to cloudwatch.
Install awslog agent on ec2 instance.
sudo yum install awslogs
Edit file /etc/awslogs/awslogs.conf and verify following lines
[/var/log/mongodb/mongodb.log]
datetime_format = %b %d %H:%M:%S
file = /var/log/mongodb/mongodb.log
buffer_duration = 5000
log_stream_name = {instance_id}
initial_position = start_of_file
log_group_name = AMZ-2
Start and enable awslogsd service by typing the command:
$ sudo service awslogsd start
$ sudo systemctl enable awslogsd