Created
April 23, 2022 20:47
-
-
Save FL33TW00D/76e1e0bc66d87b38f2eac35ca61ce695 to your computer and use it in GitHub Desktop.
Bunyan format logs from Digital Ocean
This file contains hidden or 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 | |
deployment_id=`doctl apps list | grep -m 1 -Eo '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' | head -1` | |
curdate=`gdate +%s` | |
logs=`doctl apps logs ${deployment_id} --tail 10000 > logs/$PROJECT_NAME-${curdate}.log` | |
sed -i '' 's/$PROJECT_NAME .*{/{/g' logs/$PROJECT_NAME-${curdate}.log | |
cat logs/$PROJECT_NAME-${curdate}.log | bunyan | |
if [ $? -eq 0 ]; then | |
echo Successfully retrieved and tailed logs for ${deployment_id} | |
else | |
echo Failed to tail logs | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment