Skip to content

Instantly share code, notes, and snippets.

@onisaint
Last active June 7, 2024 08:03
Show Gist options
  • Select an option

  • Save onisaint/4c1864360ebca6e240acd2108f82b379 to your computer and use it in GitHub Desktop.

Select an option

Save onisaint/4c1864360ebca6e240acd2108f82b379 to your computer and use it in GitHub Desktop.
Query logs from a distributed monolits

Usage

the script assumes the logs are in ./_lgs folder, the files are named as [server]-api.log. Also jq is installed

> sh ./ql [server-short-character] [jq-query]
#!/bin/bash
declare -A servers
servers["a"]="auth"
servers["e"]="edge"
servers["av"]="avatars"
servers["ev"]="events"
servers["sy"]="sync"
servers["fi"]="files"
_files() {
file="${servers["$1"]}"
if [[ "$file" != "" ]]; then
echo | cat "./._lgs/${file}-api.log"
else
for sv in "${!servers[@]}"; do
echo | cat "./._lgs/${servers[$sv]}-api.log"
done
fi
}
_q=$1
_f=""
if [[ "$1" =~ ^[aesf] ]]; then
_f=$1
_q=$2
fi
_files $_f | jq "$_q"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment