forked from hedyorg/hedy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdownload-logs
executable file
·33 lines (26 loc) · 1016 Bytes
/
download-logs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
set -eu
scriptdir=$(cd $(dirname $0) && pwd)
if ! type aws > /dev/null; then
echo "Install the AWS CLI before running this script." >&2
exit 1
fi
hedy_env=$1
day=$2
cache_root=~/.cache/hedy-logs/${hedy_env}
cache_dir=${cache_root}/${day}
mkdir -p "$cache_dir"
export AWS_DEFAULT_REGION=eu-central-1
export AWS_PROFILE=hedy-logs-viewer
bucket=hedy-query-logs
aws s3 sync s3://${bucket}/${hedy_env}/${day} $cache_dir
# Need to make sure every file ends in a newline
finalfile=$cache_root/$day.jsonl
sed -e '$a\' $cache_dir/* > $finalfile
echo "Now run a command like:"
echo ""
echo "Page loads that take a long time:"
echo " cat $finalfile | recs grep '{{duration_ms}} > 1000' | tee _lastquery.jsonl | recs totable -k start_time,duration_ms,method,path,'!_ms\$!' | less -S"
echo ""
echo "Count of failures:"
echo " cat $finalfile | recs grep '{{http_code}} ne 200' | tee _lastquery.jsonl | recs collate -k http_code,method,path -a count | recs sort -k count=-n | recs totable | less -S"