Queries to show GoodJob queue latency, runtime, and counts in Blazer
Last active
September 13, 2023 15:55
-
-
Save bkeepers/f44335bd2a65a5f47084cdad9ffa3470 to your computer and use it in GitHub Desktop.
good_job queries to make latency/runtime graphs
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 date_trunc('hour', created_at), queue_name, count(*) | |
FROM "good_job_executions" | |
GROUP BY 1, 2 | |
ORDER BY 1 DESC |
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
WITH jobs AS ( | |
SELECT | |
*, | |
ROUND(EXTRACT(epoch FROM (created_at - scheduled_at)) * 1000)::integer AS latency | |
FROM "good_job_executions" | |
) | |
SELECT | |
date_trunc('minute', created_at) as minute, | |
queue_name, | |
count(*) as jobs | |
FROM jobs | |
WHERE latency > 1000 | |
AND created_at >= NOW() - INTERVAL '30 minutes' | |
GROUP BY 1, 2 | |
ORDER BY 1 |
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
WITH jobs AS ( | |
SELECT | |
created_at, | |
ROUND(EXTRACT(epoch FROM (created_at - scheduled_at)) * 1000)::integer AS latency | |
FROM "good_job_executions" | |
) | |
SELECT | |
date_trunc('hour', created_at), | |
MAX(latency) as "max", | |
percentile_disc(0.99) within group (order by latency) AS "99th", | |
percentile_disc(0.95) within group (order by latency) AS "95th", | |
percentile_disc(0.5) within group (order by latency) AS "50th" | |
FROM jobs | |
GROUP BY 1 | |
ORDER BY 1 DESC |
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
WITH jobs AS ( | |
SELECT created_at, | |
ROUND(EXTRACT(epoch FROM (finished_at - created_at)) * 1000)::integer AS runtime | |
FROM "good_job_executions" | |
) | |
SELECT | |
date_trunc('hour', created_at), | |
MAX(runtime) as "max", | |
percentile_disc(0.99) within group (order by runtime) AS "99th", | |
percentile_disc(0.95) within group (order by runtime) AS "95th", | |
percentile_disc(0.5) within group (order by runtime) AS "50th" | |
FROM jobs | |
GROUP BY 1 | |
ORDER BY 1 DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment