Skip to content

Commit ebb7831

Browse files
Merge pull request #4881 from linuxfoundation/unicron-cla-stats-from-logs-prod
Unicron cla stats from logs prod
2 parents a8c0006 + 75c7297 commit ebb7831

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
# Copyright The Linux Foundation and each contributor to LFX.
3+
# SPDX-License-Identifier: MIT
4+
if [ -z "${STAGE}" ]
5+
then
6+
export STAGE=dev
7+
fi
8+
# Array of log group configurations: "region log_group_name"
9+
log_groups=(
10+
"us-east-1 /aws/lambda/cla-backend-${STAGE}-api-v3-lambda"
11+
"us-east-1 /aws/lambda/cla-backend-${STAGE}-apiv1"
12+
"us-east-1 /aws/lambda/cla-backend-${STAGE}-apiv2"
13+
"us-east-1 /aws/lambda/cla-backend-${STAGE}-githubactivity"
14+
"us-east-1 /aws/lambda/cla-backend-${STAGE}-githubinstall"
15+
"us-east-2 /aws/lambda/cla-backend-go-api-v4-lambda"
16+
)
17+
18+
for entry in "${log_groups[@]}"; do
19+
region=$(echo "$entry" | awk '{print $1}')
20+
log_group=$(echo "$entry" | cut -d' ' -f2-)
21+
aws --region "$region" --profile "lfproduct-${STAGE}" logs filter-log-events \
22+
--log-group-name "$log_group" \
23+
--start-time 0 --limit 1 --filter-pattern "\"LG:api-request-path\"" \
24+
| jq -r '.events.[0].timestamp' \
25+
| awk '{print strftime("%Y-%m-%d %H:%M:%S", $1/1000)}'
26+
done

0 commit comments

Comments
 (0)