Skip to main content
Marcel Krčah

Reading AWS CloudWatch logs with CLI and fzf

Published on , in ,

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:

# 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
}

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