Skip to content

Instantly share code, notes, and snippets.

@vilasmaciel
Created November 9, 2022 10:29
Show Gist options
  • Save vilasmaciel/add293657c9dd35bfff22e3266852384 to your computer and use it in GitHub Desktop.
Save vilasmaciel/add293657c9dd35bfff22e3266852384 to your computer and use it in GitHub Desktop.
cwtail() {
time=""
filter=""
if ! [ -z $1 ] && ! [ -z $2 ] ;
then
filter=$1
time=$2
fi
if ! [ -z $1 ] && [ -z $2 ] && [[ $1 =~ ^-b ]];
then
time=$1
else
filter=$1
fi
if [ -z $filter ];
then
selected=( $(cw ls groups | fzf --height 60% --reverse) )
else
selected=( $(cw ls groups | grep $filter | fzf --height 60% --reverse) )
fi
if ! [ -z $selected ];
then
echo "cw tail -ft $selected $time"
cw tail -ft $selected $time
fi
}
@vilasmaciel
Copy link
Author

vilasmaciel commented Nov 9, 2022

Too for consuming CloudWatch logs.

Dependencies:

  • fzf: brew install fzf
  • cw: brew tap lucagrulla/tap & brew install cw

Installation:

  1. Save the function to your .zshrc or similar
  2. Check that you have set correctly your aws credentials
  3. Install dependencies
  4. Enjoy

Usage:

cwtail - list all log sources
cwtail <word> - list all log sources filtering with the given word
cwtail | grep <word> - apply the grep command to the sected log source
cwtail -b1h - return logs from 1 hour ago

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment