Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Median and 95th percentile duration of requests by day #350

Open
trieloff opened this issue Feb 11, 2021 · 0 comments
Open

Get Median and 95th percentile duration of requests by day #350

trieloff opened this issue Feb 11, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@trieloff
Copy link
Contributor

WITH durations AS (
    SELECT 
        TIMESTAMP_MICROS(CAST(time_start_usec AS INT64)) AS time, 
        CAST(time_elapsed_usec AS INT64) AS duration,
        status_code
    FROM `helix-225321.helix_logging_1McGRQOYFuABWBHyD8D4Ux.requests202*`
    WHERE 
        status_code = "200" AND 
        resp_http_Content_Type LIKE "text/html%" AND 
        fastly_info_state LIKE "MISS%"
)
SELECT
    DATE(EXTRACT(YEAR FROM time), EXTRACT(MONTH FROM time), EXTRACT(DAY FROM time)) AS date,
    COUNT(time) AS reqs,
    APPROX_QUANTILES(duration, 100)[OFFSET(50)]/1000000 AS median_duration,
    APPROX_QUANTILES(duration, 100)[OFFSET(95)]/1000000 AS duration_95th
FROM durations
GROUP BY date
ORDER BY date ASC
@trieloff trieloff added the enhancement New feature or request label Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant