Created
February 15, 2022 23:39
-
-
Save bootandy/2be54f4f4c2e5942cdb6c310789a6233 to your computer and use it in GitHub Desktop.
# Script to tail logs of given kube service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to tail logs of given kube service | |
if [ $# -eq 0 ] | |
then | |
printf "Give me a service to look for" | |
exit 1 | |
fi | |
# Join function that supports a multi-character separator (copied from http://stackoverflow.com/a/23673883/398441) | |
function join() { | |
# $1 is return variable name | |
# $2 is sep | |
# $3... are the elements to join | |
local retname=$1 sep=$2 ret=$3 | |
shift 3 || shift $(($#)) | |
printf -v "$retname" "%s" "$ret${@/#/$sep}" | |
} | |
to_ignore="RedisCacheRepository|IdentityService.GetCallingIdentity|IdentityService.GetEmailByUserId|CosmosEntityRepository" | |
services=`kubectl get pods | rg $1 | cut -f 1 -d ' '` | |
cmmand=(); | |
for pod in ${services[@]}; do | |
cmmands+=("kubectl logs -f ${pod} --since 10s | jq -r '.LogLevel + \" \"+ .Message + \" \"+.Exception' --unbuffered | rg --line-buffered -v '${to_ignore}'"); | |
done | |
final_command=""; | |
join final_command " & " "${cmmands[@]}" | |
#printf "${final_command}\n" | |
eval "${final_command}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment