Adding MC-NIB support
[ric-app/mc.git] / mc-core / mc / queries / dc_conn_stats.gsql
1 DEFINE{query_name 'dc_connect';
2         max_lfta_disorder '1'; max_hfta_disorder '1';
3 }
4 PARAM{ window uint; }
5 select timestamp_ms as timestamp,
6         UINT(id_MeNB_UE_X2AP_ID) as eUE_ID,
7         UINT(id_SgNB_UE_X2AP_ID) as gUE_ID,
8         1 as event_type
9 from RECONCOMPLETE.reconfig_success
10 // where schemaId=101
11 ;
12
13 DEFINE{query_name 'dc_terminate';
14         max_lfta_disorder '1'; max_hfta_disorder '1';
15 }
16 PARAM{ window uint; }
17 select timestamp_ms as timestamp,
18         UINT(id_Old_eNB_UE_X2AP_ID) as eUE_ID,
19         id_SgNB_UE_X2AP_ID as gUE_ID,
20         0 as event_type
21 from CONRELEASE.dc_release
22 // where schemaId=201
23 ;
24
25 DEFINE{query_name 'dc_events';}
26 PARAM{ window uint; }
27 merge p1.timestamp : p2.timestamp
28 from dc_connect p1, dc_terminate p2
29 ;
30
31
32 DEFINE{ query_name 'mc_connected_ues'; 
33         max_lfta_disorder '1'; max_hfta_disorder '1';
34 }
35 PARAM{ window uint; }
36 SELECT TB, UE_ID,
37         ((TB+1)*$window-LAST(timestamp))/1000.0 as connected_time
38 FROM dc_events
39 GROUP BY timestamp / $window as TB, gUE_ID as UE_ID
40 HAVING LAST(event_type) = 1
41 CLOSING_WHEN LAST(event_type) = 0
42 ;
43
44 DEFINE{ query_name 'mc_connected_cnt'; 
45         max_lfta_disorder '1'; max_hfta_disorder '1';
46         comment 'Number of dual connected users';
47 }
48 PARAM{ window uint; }
49 SELECT ($window*(TB+1))/1000 as TS, 
50                 $window/1000.0 as measurementInterval, // standard_name
51       COUNT(*) as count_connected_ue
52 FROM mc_connected_ues
53 GROUP BY TB
54 ;
55
56 DEFINE{ query_name 'mc_disconnected_ues'; 
57         max_lfta_disorder '1'; max_hfta_disorder '1';
58 }
59 PARAM{ window uint; }
60 SELECT TB_1000, UE_ID, 
61         UINT((LAST(timestamp) - FIRST(timestamp))) as connected_time
62 FROM dc_events
63 GROUP BY timestamp / 1000  as TB_1000, gUE_ID as UE_ID
64 HAVING LAST(event_type) = 0
65 CLOSING_WHEN LAST(event_type) = 0
66 ;
67
68
69 DEFINE{ query_name 'mc_connection_stats'; 
70         max_lfta_disorder '1'; max_hfta_disorder '1';
71         comment 'statistics about the length of dual connected sessions';
72 }
73 PARAM{ window uint; }
74 SELECT ($window*(TB+1))/1000 as TS, 
75         $window/1000.0 as measurementInterval, // standard_name
76         MIN(connected_time)/1000.0 as min_connected_time,
77         MAX(connected_time)/1000.0 as max_connected_time,
78         AVG(connected_time)/1000.0 as avg_connected_time,
79         quantile_of(connected_time, .05)/1000.0 as pctl_05_connected_time,
80         quantile_of(connected_time, .95)/1000.0 as pctl_95_connected_time,
81         sqrt(
82                 sum((connected_time/1000.0)*(connected_time/1000.0)) - sum(connected_time/1000.0)*sum(connected_time/1000.0)/count(*)
83         ) / count(*) as stddev_connected_time
84 FROM mc_disconnected_ues
85 GROUP BY (TB_1000 * 1000) / $window as TB
86 ;
87
88
89 DEFINE{ query_name 'mc_connects_cnt'; 
90         max_lfta_disorder '1'; max_hfta_disorder '1';
91         comment 'number of DC connection requests';
92 }
93 PARAM{ window uint; }
94 SELECT ($window*(TB+1))/1000 as TS,
95         $window/1000.0 as measurementInterval, // standard_name
96         COUNT(*) as count_ue_connects
97 FROM dc_events
98 WHERE event_type = 1
99 GROUP BY timestamp / $window as TB
100 ;
101
102 DEFINE{ query_name 'mc_disconnects_cnt'; 
103         max_lfta_disorder '1'; max_hfta_disorder '1';
104         comment 'number of DC connection releases';
105 }
106 PARAM{ window uint; }
107 SELECT ($window*(TB+1))/1000 as TS, 
108          $window/1000.0 as measurementInterval, // standard_name
109          COUNT(*) as count_ue_disconnects
110 FROM dc_events
111 WHERE event_type = 0
112 GROUP BY timestamp / $window as TB
113 ;
114
115 DEFINE{ query_name 'mc_unique_ues'; 
116         max_lfta_disorder '1'; max_hfta_disorder '1';
117 }
118 PARAM{ window uint; }
119 SELECT TB, UE_ID
120 FROM dc_events
121 GROUP BY timestamp / $window as TB, gUE_ID as UE_ID
122 ;
123
124 DEFINE{ query_name 'mc_unique_ue_cnt'; 
125         max_lfta_disorder '1'; max_hfta_disorder '1';
126         comment 'Number of distinct UEs making a DC request or release';
127 }
128 PARAM{ window uint; } 
129 SELECT ($window*(TB+1))/1000 as TS, 
130          $window/1000.0 as measurementInterval, // standard_name
131          COUNT(*) as count_unique_ue
132 FROM mc_unique_ues
133 GROUP BY TB
134
135
136