2023-09-18 01:53:10 -04:00
|
|
|
#!/bin/bash
|
|
|
|
read -r -d '' ASNS <<- EOF
|
2023-09-18 02:12:36 -04:00
|
|
|
8075: microsoft (github actions)
|
2023-09-18 01:53:10 -04:00
|
|
|
EOF
|
|
|
|
read -r -d '' SQL <<- EOF
|
|
|
|
SELECT
|
|
|
|
index1 as status_code,
|
|
|
|
blob1 as method,
|
|
|
|
blob2 as country,
|
|
|
|
blob3 as asn,
|
|
|
|
blob4 as timezone,
|
|
|
|
blob5 as timestamp,
|
2023-09-18 02:12:36 -04:00
|
|
|
blob6 as ip,
|
|
|
|
blob7 as referer
|
2023-09-18 01:53:10 -04:00
|
|
|
FROM METRICS WHERE
|
|
|
|
timestamp != '' and
|
|
|
|
ip != '$LOCAL_IP' and
|
|
|
|
asn != '8075'
|
|
|
|
ORDER BY timestamp
|
|
|
|
EOF
|
2023-09-18 02:12:36 -04:00
|
|
|
read -r -d '' JQ <<- EOF
|
2023-09-18 22:14:26 -04:00
|
|
|
.data[] | [
|
|
|
|
if .status_code == "" then "200" else .status_code end,
|
|
|
|
.method,
|
|
|
|
.country,
|
|
|
|
.asn,
|
|
|
|
.timezone,
|
|
|
|
.timestamp,
|
|
|
|
.ip,
|
|
|
|
.referer ] | @tsv
|
2023-09-18 02:12:36 -04:00
|
|
|
EOF
|
2023-09-18 22:14:26 -04:00
|
|
|
curl -X POST "https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/analytics_engine/sql" -H "Authorization: Bearer $CF_API_TOKEN" -d "$SQL" 2>/dev/null | jq "$JQ" -r | grep -v '2023-09-18T05:20' | column -tN "ret,verb,xw,asn,tz,ts,ip,ref"
|