Reading AWS CloudWatch logs with CLI and fzf
It turns out it is possible to read AWS Cloudwatch logs in a command-line with using aws logs
. So I created a simple wrapper script with fzf that:
- lets me interactively choose an AWS profile from
.aws/config
- lets me select a CloudWatch log group name
# bash function in my .rc file
awslogs() {
set -e
export AWS_PROFILE=$(cat ~/.aws/config | awk '/^\[profile /{print $2}' | tr -d ']' | fzf)
local log_group=$(aws logs describe-log-groups | jq -r '.logGroups[].logGroupName' | fzf)
aws logs tail "$log_group" --since 3h --follow --format=short
}
- ← Previous post: Parameterize AWS Lambda with SSM Param Store
- → Next post: Business metrics for system maintenance
This blog is written by Marcel Krcah, an independent consultant for product-oriented software engineering. If you like what you read, sign up for my newsletter