Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS EC2 get system log [closed]

I'm trying to get the System log from a Linux EC2 instance, either in the logs file or the command line.

I can get them from the console but they are always stale.

aws ec2 get-console-output --instance-id <my-ec2-id>

Is asking for Region, Access keys etc etc.

Is there any easy way of just getting the log from the current instance?

like image 397
beek Avatar asked Jul 03 '17 03:07

beek


1 Answers

Both of the ways that you described (the web console and the CLI) are "the easy ways". Yes, they are not updated frequently and are buffered for varying durations before being updated.

From the docs:

For Linux/Unix instances, the instance console output displays the exact console output that would normally be displayed on a physical monitor attached to a computer. This output is buffered because the instance produces it and then posts it to a store where the instance's owner can retrieve it.

For Windows instances, the instance >console output displays the last three system event log errors.

The posted output is not continuously updated; only when it is likely to be of the most value. This includes shortly after instance boot, after reboot, and when the instance terminates.

Note: Only the most recent 64 KB of posted output is stored, which is available for at least 1 hour after the last posting.

Out-of-the-box there are no easier ways to view syslogs from any vanilla EC2 instance. On an Ubuntu instance, you could SSH in and tail follow /var/log/syslog. You could set up something like frontail to stream these logs to your browser, but be careful to secure access to the endpoint using restrictive security groups.

like image 127
Jedi Avatar answered Oct 05 '22 23:10

Jedi