Skip to content

Instantly share code, notes, and snippets.

@kenorb
Last active April 5, 2019 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenorb/bdceea9dea9cc3a42bfc21346f6f17d4 to your computer and use it in GitHub Desktop.
Save kenorb/bdceea9dea9cc3a42bfc21346f6f17d4 to your computer and use it in GitHub Desktop.
ELB: Most consuming URLs
CREATE OR REPLACE VIEW url_53847374125428073109782528 AS
SELECT
"sum"("backend_processing_time") "total_ms"
, "url"
FROM
elb_logs_2019
WHERE (("split_part"("request_timestamp", 'T', 1) LIKE '2019-01-%') AND ("regexp_extract"("url", 'sessionId=(.*)', 1) = '53847374125428073109782528'))
GROUP BY "url"
ORDER BY "total_ms" DESC
LIMIT 200
CREATE OR REPLACE VIEW this_month_most_consuming_urls AS
SELECT
"sum"("backend_processing_time") "total_ms"
, "url"
FROM
elb_logs_2019
WHERE ("split_part"("request_timestamp", 'T', 1) LIKE '2019-01-%')
GROUP BY "url"
ORDER BY "total_ms" DESC
LIMIT 50
CREATE OR REPLACE VIEW todays_most_consuming_urls AS
SELECT
"sum"("backend_processing_time") "total_ms"
, "url"
FROM
elb_logs_2019
WHERE ("split_part"("request_timestamp", 'T', 1) = "split_part"("to_iso8601"(current_timestamp), 'T', 1))
GROUP BY "url"
ORDER BY "total_ms" DESC
LIMIT 50
CREATE OR REPLACE VIEW total_most_consuming_ips AS
SELECT
"sum"("backend_processing_time") "total_ms"
, "request_ip"
FROM
elb_logs_2019
WHERE ("backend_ip" <> '')
GROUP BY "request_ip"
ORDER BY "total_ms" DESC
LIMIT 50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment