Skip to content

Commit 94a552d

Browse files
author
Roberto Sora
authored
[skip changelog] Add partition load query before fetching metrics and schedule extraction 3 times a day (#1471)
1 parent f03580c commit 94a552d

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

Diff for: .github/tools/fetch_athena_stats.sh

+28-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,34 @@
1414

1515
set -euo pipefail
1616

17+
loadExecutionId=$(
18+
aws athena start-query-execution \
19+
--query-string "MSCK REPAIR TABLE ${AWS_ATHENA_SOURCE_TABLE};" \
20+
--result-configuration "OutputLocation=${AWS_ATHENA_OUTPUT_LOCATION}" \
21+
--region us-east-1 | jq -r ".QueryExecutionId"
22+
)
23+
24+
echo "QueryExecutionId is ${loadExecutionId}"
25+
for i in $(seq 1 120); do
26+
loadState=$(
27+
aws athena get-query-execution \
28+
--query-execution-id "${loadExecutionId}" \
29+
--region us-east-1 | jq -r ".QueryExecution.Status.State"
30+
)
31+
32+
if [[ "${loadState}" == "SUCCEEDED" ]]; then
33+
break
34+
fi
35+
36+
echo "QueryExecutionId ${loadExecutionId} - state is ${loadState}"
37+
38+
if [[ "${loadState}" == "FAILED" ]]; then
39+
exit 1
40+
fi
41+
42+
sleep 2
43+
done
44+
1745
! read -r -d '' query <<EOM
1846
SELECT replace(json_extract_scalar(url_decode(url_decode(querystring)),
1947
'$.data.url'), 'https://downloads.arduino.cc/arduino-cli/arduino-cli_', '') AS flavor, count(json_extract(url_decode(url_decode(querystring)),'$')) AS gauge
@@ -28,7 +56,6 @@ EOM
2856
queryExecutionId=$(
2957
aws athena start-query-execution \
3058
--query-string "${query}" \
31-
--query-execution-context "Database=demo_books" \
3259
--result-configuration "OutputLocation=${AWS_ATHENA_OUTPUT_LOCATION}" \
3360
--region us-east-1 | jq -r ".QueryExecutionId"
3461
)

Diff for: .github/workflows/arduino-stats.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: arduino-stats
22

33
on:
44
schedule:
5-
# run every day at 12:30:00
6-
- cron: "30 12 * * *"
5+
# run every day at 07:00 AM, 03:00 PM and 11:00 PM
6+
- cron: "0 7,15,23 * * *"
77
workflow_dispatch:
88
repository_dispatch:
99

0 commit comments

Comments
 (0)