spiritedmedia / systems

Code and documentation for building, deploying, and serving code.
1 stars 1 forks source link

Update AWS CloudWatch Log Monitor Config #31

Closed kingkool68 closed 6 years ago

kingkool68 commented 7 years ago

The debug.log stream wasn't updating. Turns out we need to specify the log format is in UTC time not local time. Always we want to set log_stream_name to the {instance_id}. This lets us stream the logs to AWS CloudWatch where we can look at an individual stream or a combined stream in a log group. Nifty.

Update AWS CloudWatch log monitor config at /var/awslogs/etc/awslogs.conf

[/var/nginx/spiritedmedia.com.error.log]
datetime_format = %Y/%m/%d %H:%M:%S
file = /var/log/nginx/spiritedmedia.com.error.log
buffer_duration = 5000
log_stream_name = {instance_id}
initial_position = start_of_file
log_group_name = /var/log/nginx/spiritedmedia.com.error.log

[/var/log/nginx/error.log]
datetime_format = %Y/%m/%d %H:%M:%S
file = /var/log/nginx/error.log
buffer_duration = 5000
log_stream_name = {instance_id}
initial_position = start_of_file
log_group_name = /var/log/nginx/error.log

[/var/nginx/spiritedmedia.com.access.log]
datetime_format = %d/%b/%Y %H:%M:%S %z
file = /var/log/nginx/spiritedmedia.com.access.log
buffer_duration = 5000
log_stream_name = {instance_id}
initial_position = start_of_file
log_group_name = /var/log/nginx/spiritedmedia.com.access.log

[/var/www/spiritedmedia.com/htdocs/wp-content/debug.log]
datetime_format = %d-%b-%Y %H:%M:%S
time_zone = UTC
file = /var/www/spiritedmedia.com/htdocs/wp-content/debug.log
buffer_duration = 5000
log_stream_name = {instance_id}
initial_position = start_of_file
log_group_name = /var/www/spiritedmedia.com/htdocs/wp-content/debug.log

Be sure to restart the logging daemon: sudo service awslogs restart

Probably a good idea to delete the debug.log file as well.