Skip to content

Instantly share code, notes, and snippets.

@vinoaj
Last active March 14, 2019 22:45
Show Gist options
  • Save vinoaj/8ce8e81f7169184901e2c9b4ac7b8d4d to your computer and use it in GitHub Desktop.
Save vinoaj/8ce8e81f7169184901e2c9b4ac7b8d4d to your computer and use it in GitHub Desktop.
WITH error_stats AS (
SELECT
labels.execution_id as execution_id
, MIN(resource.labels.function_name) as name
, MAX(IF(severity="ERROR", 1, 0)) as error
FROM `<dataset_id>.logging.cloudfunctions_googleapis_com_cloud_functions_*`
WHERE _TABLE_SUFFIX BETWEEN '20190101' AND '20190315'
GROUP BY labels.execution_id
)
SELECT
name
, ROUND((SUM(error)/COUNT(error)), 2) as proportion_with_errors
FROM error_stats
GROUP BY name
ORDER BY proportion_with_errors DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment