Created
June 30, 2023 09:15
-
-
Save kevinsimper/c9e9c608ac5ce81b628181a7f201cf9e to your computer and use it in GitHub Desktop.
Normalized URL in bigquery for Next.js routes
This file contains hidden or 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
SELECT | |
normalizedUrl, | |
COUNT(1) | |
FROM ( | |
SELECT | |
httpRequest.requestUrl, | |
REGEXP_REPLACE(REGEXP_REPLACE(REGEXP_REPLACE(httpRequest.requestUrl, r'/_next/data/[^/]+', ''), r'\d+', '[id]'), r'\.json', '') AS normalizedUrl | |
FROM | |
`greenmobility.cloudrun_requests.run_googleapis_com_requests` | |
WHERE | |
TIMESTAMP_TRUNC(timestamp, DAY) > TIMESTAMP("2023-01-28") ) | |
WHERE | |
normalizedUrl LIKE '%.com/admin/%' | |
# AND normalizedUrl LIKE '%package%' | |
GROUP BY | |
normalizedUrl | |
ORDER BY | |
2 desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment