@@ -6,9 +6,9 @@ GRANT USAGE ON SCHEMA views TO ${NAMESPACE}_quicksight_user;
66DROP MATERIALIZED VIEW IF EXISTS views .mv_01_auth_usage__data__last_calls CASCADE;
77
88-- Repeat the same query with three time different time period
9- -- Last 5 entire minutes. At 14:05:06 this interval is [ 14:00:00, 14:05:00 [
109-- Last 15 entire minutes. At 14:05:06 this interval is [ 13:50:00, 14:05:00 [
1110-- Last 30 entire minutes. At 14:05:06 this interval is [ 13:35:00, 14:05:00 [
11+ -- Last 45 entire minutes. At 14:05:06 this interval is [ 13:20:00, 14:05:00 [
1212-- N.B.: this view in not an "incremental refresh one" it will be recomputed at
1313-- every "refresh lambda" execution
1414CREATE MATERIALIZED VIEW views .mv_01_auth_usage__data__last_calls as
@@ -22,13 +22,14 @@ CREATE MATERIALIZED VIEW views.mv_01_auth_usage__data__last_calls as
2222 sum ( quantity_4xx ) as quantity_4xx,
2323 sum ( total_4xx_execution_time ) as total_4xx_execution_time,
2424 sum ( quantity_5xx ) as quantity_5xx,
25- date_add(' minute' , - 1 * 5 , date_trunc( ' minute' , getdate() ) ) as from_ts,
25+ date_add(' minute' , - 1 * 15 , date_trunc( ' minute' , getdate() ) ) as from_ts,
2626 date_trunc( ' minute' , getdate() ) as to_ts,
27- 5 as period_length_minutes
27+ 15 as period_length_minutes,
28+ max (minute_slot) as last_minute_with_requests
2829 from
2930 views .mv_00_auth_usage__data__calls
3031 where
31- minute_slot between date_add(' minute' , - 1 * 5 , date_trunc( ' minute' , getdate() ) )
32+ minute_slot between date_add(' minute' , - 1 * 15 , date_trunc( ' minute' , getdate() ) )
3233 and date_trunc( ' minute' , getdate() )
3334 group by
3435 consumer_name,
@@ -44,13 +45,14 @@ UNION ALL
4445 sum ( quantity_4xx ) as quantity_4xx,
4546 sum ( total_4xx_execution_time ) as total_4xx_execution_time,
4647 sum ( quantity_5xx ) as quantity_5xx,
47- date_add(' minute' , - 1 * 15 , date_trunc( ' minute' , getdate() ) ) as from_ts,
48+ date_add(' minute' , - 1 * 30 , date_trunc( ' minute' , getdate() ) ) as from_ts,
4849 date_trunc( ' minute' , getdate() ) as to_ts,
49- 15 as period_length_minutes
50+ 30 as period_length_minutes,
51+ max (minute_slot) as last_minute_with_requests
5052 from
5153 views .mv_00_auth_usage__data__calls
5254 where
53- minute_slot between date_add(' minute' , - 1 * 15 , date_trunc( ' minute' , getdate() ) )
55+ minute_slot between date_add(' minute' , - 1 * 30 , date_trunc( ' minute' , getdate() ) )
5456 and date_trunc( ' minute' , getdate() )
5557 group by
5658 consumer_name,
@@ -66,13 +68,14 @@ UNION ALL
6668 sum ( quantity_4xx ) as quantity_4xx,
6769 sum ( total_4xx_execution_time ) as total_4xx_execution_time,
6870 sum ( quantity_5xx ) as quantity_5xx,
69- date_add(' minute' , - 1 * 30 , date_trunc( ' minute' , getdate() ) ) as from_ts,
71+ date_add(' minute' , - 1 * 45 , date_trunc( ' minute' , getdate() ) ) as from_ts,
7072 date_trunc( ' minute' , getdate() ) as to_ts,
71- 30 as period_length_minutes
73+ 45 as period_length_minutes,
74+ max (minute_slot) as last_minute_with_requests
7275 from
7376 views .mv_00_auth_usage__data__calls
7477 where
75- minute_slot between date_add(' minute' , - 1 * 30 , date_trunc( ' minute' , getdate() ) )
78+ minute_slot between date_add(' minute' , - 1 * 45 , date_trunc( ' minute' , getdate() ) )
7679 and date_trunc( ' minute' , getdate() )
7780 group by
7881 consumer_name,
0 commit comments