forked from hedyorg/hedy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add some scripts to look at logs
- Loading branch information
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# How to access query logs? | ||
|
||
|
||
## Prerequisites | ||
|
||
Ask someone in the team for the credentials of the `hedy-logs-viewer` IAM user. Add the following to the | ||
`~/.aws/credentials` file: | ||
|
||
``` | ||
[hedy-logs-viewer] | ||
aws_access_key_id = AKIA********** | ||
aws_secret_access_key = *********** | ||
``` | ||
|
||
Install The Log File Navigator (`lnav`) using one of the methods described [here](http://lnav.org/downloads). | ||
|
||
Install the [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv1.html). | ||
|
||
## Usage | ||
|
||
Run: | ||
|
||
``` | ||
$ tools/view-logs <APP> <YYYY-MM-DD> | ||
# Example: | ||
$ tools/view-logs hedy-beta 2021-05-10 | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"request": { | ||
"title": "JSON Request Log", | ||
"description": "Log format for JSON request logs", | ||
"json": true, | ||
"file-pattern": "\\.jsonl$", | ||
"line-format": [ | ||
{ "field": "start_time" }, | ||
" ", | ||
{ "field": "method" }, | ||
" ", | ||
{ "field": "path" }, | ||
": ", | ||
{ "field": "duration_ms" } | ||
], | ||
"level-field": "fault", | ||
"level": { | ||
"error": 1, | ||
"info": 0 | ||
}, | ||
"timestamp-field": "start_time", | ||
"body-field": "path", | ||
"value": { | ||
"start_time": { "kind": "string" }, | ||
"path": { "kind": "string" }, | ||
"method": { "kind": "string" }, | ||
"duration_ms": { "kind": "integer" }, | ||
"fault": { "kind": "integer" } | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
set -eu | ||
scriptdir=$(cd $(dirname $0) && pwd) | ||
|
||
if ! type lnav > /dev/null; then | ||
echo "Install 'lnav' before running this script! (http://lnav.org)" >&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 | ||
sed -i -e '$a\' $cache_dir/* | ||
|
||
#finalfile=$cache_root/$day.jsonl | ||
#rm -f $finalfile | ||
#for f in $cache_dir/*; do (cat "${f}"; echo) >> $finalfile; done | ||
|
||
lnav -i $scriptdir/jsonlines_fmt.json | ||
lnav -r $cache_dir |