daily pastebin goal
70%
SHARE
TWEET

Untitled

a guest Mar 19th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WITH avg_runtimes AS (
  2.   SELECT
  3.     resource.labels.function_name AS function_name
  4.     , AVG(CAST(REGEXP_EXTRACT(textPayload, r"\d+") AS INT64)) AS avg_runtime
  5.   FROM `<dataset_id>.logging.cloudfunctions_googleapis_com_cloud_functions_*`
  6.   WHERE _TABLE_SUFFIX BETWEEN '20190101' AND '20190315'
  7.     AND REGEXP_CONTAINS(textPayload, r"^Function execution took \d+ ms.*")
  8.   GROUP BY resource.labels.function_name
  9. )
  10. SELECT
  11.   resource.labels.function_name
  12.   , labels.execution_id
  13.   , timestamp
  14.   , CAST(REGEXP_EXTRACT(textPayload, r"\d+") AS INT64) AS runtime
  15.   , avg_runtime
  16.   , (CAST(REGEXP_EXTRACT(textPayload, r"\d+") AS INT64) - avg_runtime) AS delta_ms
  17.   , (((CAST(REGEXP_EXTRACT(textPayload, r"\d+") AS INT64)) - avg_runtime)/avg_runtime) * 100 AS delta_pct
  18. FROM
  19.   `<dataset_id>.logging.cloudfunctions_googleapis_com_cloud_functions_*` AS cf_logs
  20.   JOIN avg_runtimes ON avg_runtimes.function_name = cf_logs.resource.labels.function_name
  21. WHERE REGEXP_CONTAINS(textPayload, r"^Function execution took \d+ ms.*")
  22.   AND CAST(REGEXP_EXTRACT(textPayload, r"\d+") AS INT64) > avg_runtime * 1.3
  23. ORDER BY delta_pct DESC
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top