Skip to content

Commit 808ee41

Browse files
Update logs grepping scripts and add a script to find the first API log entry in AWS logs
Signed-off-by: Lukasz Gryglicki <[email protected]> Assisted by [OpenAI](https://platform.openai.com/) Assisted by [GitHub Copilot](https://github.com/features/copilot)
1 parent 1edadbf commit 808ee41

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

utils/calculate_api_stats.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ then
1313
exit 1
1414
fi
1515
export DTFROM="${1}"
16-
REGION=us-east-1 NO_ECHO=1 DTTO='1 second ago' OUT="api-logs-${STAGE}-1.json" ./utils/search_aws_logs.sh 'LG:api-request-path'
17-
REGION=us-east-2 NO_ECHO=1 DTTO='1 second ago' OUT="api-logs-${STAGE}-2.json" ./utils/search_aws_logs.sh 'LG:api-request-path'
16+
INCL_LOGS='githubactivity,githubinstall,apiv1,apiv2,api-v3-lambda' REGION=us-east-1 NO_ECHO=1 DTTO='1 second ago' OUT="api-logs-${STAGE}-1.json" ./utils/search_aws_logs.sh 'LG:api-request-path'
17+
INCL_LOGS='api-v4-lambda' REGION=us-east-2 NO_ECHO=1 DTTO='1 second ago' OUT="api-logs-${STAGE}-2.json" ./utils/search_aws_logs.sh 'LG:api-request-path'
1818
jq -s 'add' "api-logs-${STAGE}-1.json" "api-logs-${STAGE}-2.json" > "api-logs-${STAGE}.json" && rm -f "api-logs-${STAGE}-1.json" "api-logs-${STAGE}-2.json"
1919
./utils/count_apis.sh "api-logs-${STAGE}.json" > "api-logs-${STAGE}.log" && cat "api-logs-${STAGE}.log"
20+
cat "api-logs-${STAGE}.json" | grep '"logGroupName": "' | sort | uniq

utils/find_1st_log_entry.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
if [ -z "${STAGE}" ]
3+
then
4+
export STAGE=dev
5+
fi
6+
aws --region us-east-1 --profile "lfproduct-${STAGE}" logs filter-log-events --log-group-name "/aws/lambda/cla-backend-${STAGE}-api-v3-lambda" --start-time 0 --limit 1 --filter-pattern "\"LG:api-request-path\"" | jq -r '.events.[0].timestamp' | awk '{print strftime("%Y-%m-%d %H:%M:%S", $1/1000)}'
7+
aws --region us-east-1 --profile "lfproduct-${STAGE}" logs filter-log-events --log-group-name "/aws/lambda/cla-backend-${STAGE}-apiv1" --start-time 0 --limit 1 --filter-pattern "\"LG:api-request-path\"" | jq -r '.events.[0].timestamp' | awk '{print strftime("%Y-%m-%d %H:%M:%S", $1/1000)}'
8+
aws --region us-east-1 --profile "lfproduct-${STAGE}" logs filter-log-events --log-group-name "/aws/lambda/cla-backend-${STAGE}-apiv2" --start-time 0 --limit 1 --filter-pattern "\"LG:api-request-path\"" | jq -r '.events.[0].timestamp' | awk '{print strftime("%Y-%m-%d %H:%M:%S", $1/1000)}'
9+
aws --region us-east-1 --profile "lfproduct-${STAGE}" logs filter-log-events --log-group-name "/aws/lambda/cla-backend-${STAGE}-githubactivity" --start-time 0 --limit 1 --filter-pattern "\"LG:api-request-path\"" | jq -r '.events.[0].timestamp' | awk '{print strftime("%Y-%m-%d %H:%M:%S", $1/1000)}'
10+
aws --region us-east-1 --profile "lfproduct-${STAGE}" logs filter-log-events --log-group-name "/aws/lambda/cla-backend-${STAGE}-githubinstall" --start-time 0 --limit 1 --filter-pattern "\"LG:api-request-path\"" | jq -r '.events.[0].timestamp' | awk '{print strftime("%Y-%m-%d %H:%M:%S", $1/1000)}'
11+
aws --region us-east-2 --profile "lfproduct-${STAGE}" logs filter-log-events --log-group-name "/aws/lambda/cla-backend-go-api-v4-lambda" --start-time 0 --limit 1 --filter-pattern "\"LG:api-request-path\"" | jq -r '.events.[0].timestamp' | awk '{print strftime("%Y-%m-%d %H:%M:%S", $1/1000)}'

0 commit comments

Comments
 (0)