Marcel's notes

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

Would you like to connect? Subscribe via email or RSS , or follow me on Twitter!