View AWS CLI logs in Real-Time
Almost traditional log viewing in the AWS Console, but in real-time on your terminal!
How to tail AWS CLI logs
After installing the aws-cli on your machine, you can start tailing your logs in real-time among other AWS services. The primary use of the command requires you to specify the log group and log stream.
An example of the command is:
|
|
–follow (tail -f)
In order to tail the CloudWatch logs in real-time, add the --follow
parameter to the AWS logs tail command. The command tails the logs for a specific CloudWatch log group.
By setting the --follow
parameter, the command continuously polls for new logs.
An example of the command is:
|
|
–format
By default, the logs tail command prints the following:
- timestamp and timezone
- log stream name
- log messages
For a more readable version, set the --format
parameter to short. ( The current options are detailed
and short
, It defaults to detailed
)
An example of the command is:
|
|
–since
The aws logs tail command also enables us to view the generated logs of a CloudWatch log group for a specific time period. By default the command returns the logs from the past 10 minutes.
To return the logs from a specific time period, use the --since
parameter:
An example of the commands are:
|
|
–filter-pattern (grep)
You can filter which log messages the aws logs tail commands displays to your terminal, by using the --filter-pattern
parameter.
The following example only returns log messages that include the string Hello.
An example of the command is:
|
|