Updating a set of supported NR metrics
[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         gnb_id as gnb_id,
7         UINT(id_MeNB_UE_X2AP_ID) as eUE_ID,
8         UINT(id_SgNB_UE_X2AP_ID) as gUE_ID,
9         1 as event_type
10 from RECONCOMPLETE.reconfig_success
11 ;
12
13 --      use id_New_eNB_UE_X2AP_ID for eUE_ID ????  Or take max to combine them
14 DEFINE{query_name 'dc_terminate';
15         max_lfta_disorder '1'; max_hfta_disorder '1';
16 }
17 PARAM{ window uint; }
18 select timestamp_ms as timestamp,
19         gnb_id as gnb_id,
20         UINT(id_Old_eNB_UE_X2AP_ID) as eUE_ID,
21         id_SgNB_UE_X2AP_ID as gUE_ID,
22         0 as event_type
23 from CONRELEASE.dc_release
24 ;
25
26 DEFINE{query_name 'dc_events';}
27 PARAM{ window uint; }
28 merge p1.timestamp : p2.timestamp
29 from dc_connect p1, dc_terminate p2
30 ;
31
32 DEFINE{query_name 'dc_events_gtp_teid';
33         comment 'tag dc_events with the gtp_teid';
34         max_lfta_disorder '1'; max_hfta_disorder '1';
35 }
36 PARAM{window uint;}
37 Select M.TB, non_temporal(d.timestamp), d.gnb_id, d.eUE_ID, d.gUE_ID, d.event_type, M.gTP_TEID
38 LEFT_OUTER_JOIN from dc_events d, gnb_ueid_teid_map M
39 Where d.gnb_id=M.GNB_ID and d.gUE_ID=M.id_SgNB_UE_X2AP_ID 
40         and d.timestamp/$window=M.TB
41 ;
42
43 DEFINE{query_name 'dc_events_pci';
44         max_lfta_disorder '1'; max_hfta_disorder '1';
45         comment 'tag dc_events with the pci';
46 }
47 PARAM{ window uint; }
48 Select M.TB, non_temporal(d.timestamp) as timestamp, d.gnb_id, d.eUE_ID, d.gUE_ID, d.event_type, M.physCellId
49 LEFT_OUTER_JOIN from dc_events d, gnb_ueid_cellid_map M
50 Where d.gnb_id=M.GNB_ID and d.gUE_ID=M.id_SgNB_UE_X2AP_ID 
51         and d.timestamp/$window=M.TB
52 ;
53
54
55 DEFINE{ query_name 'mc_connected_ues'; 
56         max_lfta_disorder '1'; max_hfta_disorder '1';
57 }
58 PARAM{ window uint; }
59 SELECT TB, UE_ID, GNB_ID,
60         ((TB+1)*$window-LAST(timestamp))/1000.0 as connected_time
61 FROM dc_events
62 GROUP BY timestamp / $window as TB, gUE_ID as UE_ID, gnb_id as GNB_ID
63 HAVING LAST(event_type) = 1
64 CLOSING_WHEN LAST(event_type) = 0 OR
65                 ((TB+1)*$window-LAST(timestamp))/1000.0 >= 3600
66 ;
67
68 DEFINE{ query_name 'mc_connected_ues_pci'; 
69         max_lfta_disorder '1'; max_hfta_disorder '1';
70 }
71 PARAM{ window uint; }
72 SELECT TB, UE_ID, GNB_ID, physCellId,
73         ((TB+1)*$window-LAST(timestamp))/1000.0 as connected_time
74 FROM dc_events_pci
75 GROUP BY  TB, gUE_ID as UE_ID, gnb_id as GNB_ID, physCellId
76 HAVING LAST(event_type) = 1
77 CLOSING_WHEN LAST(event_type) = 0 OR
78                 ((TB+1)*$window-LAST(timestamp))/1000.0 >= 3600
79 ;
80
81 DEFINE{ query_name 'mc_connected_cnt'; 
82         max_lfta_disorder '1'; max_hfta_disorder '1';
83         comment 'Number of dual connected sessions';
84 }
85 PARAM{ window uint; }
86 SELECT ($window*(TB+1))/1000 as TS, GNB_ID, 
87                 $window/1000.0 as measurementInterval, // standard_name
88       COUNT(*) as count_connected_ue
89 FROM mc_connected_ues
90 GROUP BY TB,  GNB_ID
91 ;
92
93 DEFINE{ query_name 'mc_connected_cnt_pci'; 
94         max_lfta_disorder '1'; max_hfta_disorder '1';
95         comment 'Number of dual connected users by gnb and pci';
96 }
97 PARAM{ window uint; }
98 SELECT ($window*(TB+1))/1000 as TS, GNB_ID, physCellId,
99                 $window/1000.0 as measurementInterval, // standard_name
100       COUNT(*) as count_connected_ue
101 FROM mc_connected_ues_pci
102 GROUP BY TB,  GNB_ID, physCellId
103 ;
104
105
106
107 DEFINE{ query_name 'mc_disconnected_ues'; 
108         max_lfta_disorder '1'; max_hfta_disorder '1';
109 }
110 PARAM{ window uint; }
111 SELECT TB_1000, UE_ID, GNB_ID,
112         UINT((LAST(timestamp) - FIRST(timestamp))) as connected_time
113 FROM dc_events
114 GROUP BY timestamp / 1000  as TB_1000, gUE_ID as UE_ID, gnb_id as GNB_ID
115 HAVING LAST(event_type) = 0
116 CLOSING_WHEN LAST(event_type) = 0 OR
117                 ((TB_1000+1)*1000-LAST(timestamp))/1000.0 >= 3600
118 ;
119
120
121
122 DEFINE{ query_name 'mc_connection_stats'; 
123         max_lfta_disorder '1'; max_hfta_disorder '1';
124         comment 'statistics about the length of dual connected sessions by gnb';
125 }
126 PARAM{ window uint; }
127 SELECT ($window*(TB+1))/1000 as TS, GNB_ID,
128         $window/1000.0 as measurementInterval, // standard_name
129         MIN(connected_time)/1000.0 as min_connected_time,
130         MAX(connected_time)/1000.0 as max_connected_time,
131         AVG(connected_time)/1000.0 as avg_connected_time,
132         quantile_of(connected_time, .05)/1000.0 as pctl_05_connected_time,
133         quantile_of(connected_time, .95)/1000.0 as pctl_95_connected_time,
134         sqrt(
135                 sum((connected_time/1000.0)*(connected_time/1000.0)) - sum(connected_time/1000.0)*sum(connected_time/1000.0)/count(*)
136         ) / count(*) as stddev_connected_time
137 FROM mc_disconnected_ues
138 GROUP BY (TB_1000 * 1000) / $window as TB, GNB_ID
139 ;
140
141 DEFINE{ query_name 'mc_disconnected_gtp_teids'; 
142         max_lfta_disorder '1'; max_hfta_disorder '1';
143 }
144 PARAM{ window uint; }
145 Select m.TB, m.gTP_TEID, d.GNB_ID, d.connected_time
146 LEFT_OUTER_JOIN from mc_disconnected_ues d, gnb_ueid_teid_map m
147 where d.GNB_ID=m.GNB_ID and d.UE_ID=m.id_SgNB_UE_X2AP_ID and
148         (d.TB_1000 * 1000) / $window = m.TB
149 ;
150
151 DEFINE{ query_name 'mc_connection_stats_gtp_teid'; 
152         max_lfta_disorder '1'; max_hfta_disorder '1';
153         comment 'statistics about the length of dual connected sessions, by gtp_teid';
154 }
155 PARAM{ window uint; }
156 SELECT ($window*(TB+1))/1000 as TS, GNB_ID, gTP_TEID,
157         $window/1000.0 as measurementInterval, // standard_name
158         MIN(connected_time)/1000.0 as min_connected_time,
159         MAX(connected_time)/1000.0 as max_connected_time,
160         AVG(connected_time)/1000.0 as avg_connected_time,
161         quantile_of(connected_time, .05)/1000.0 as pctl_05_connected_time,
162         quantile_of(connected_time, .95)/1000.0 as pctl_95_connected_time,
163         sqrt(
164                 sum((connected_time/1000.0)*(connected_time/1000.0)) - sum(connected_time/1000.0)*sum(connected_time/1000.0)/count(*)
165         ) / count(*) as stddev_connected_time
166 FROM mc_disconnected_gtp_teids
167 GROUP BY TB, GNB_ID, gTP_TEID
168 ;
169
170
171
172
173 DEFINE{ query_name 'mc_connects_cnt'; 
174         max_lfta_disorder '1'; max_hfta_disorder '1';
175         comment 'number of DC connection requests, by GNB';
176 }
177 PARAM{ window uint; }
178 SELECT ($window*(TB+1))/1000 as TS, GNB_ID,
179         $window/1000.0 as measurementInterval, // standard_name
180         COUNT(*) as count_ue_connects
181 FROM dc_events
182 WHERE event_type = 1
183 GROUP BY timestamp / $window as TB, gnb_id as GNB_ID
184 ;
185
186 DEFINE{ query_name 'mc_connects_cnt_pci'; 
187         max_lfta_disorder '1'; max_hfta_disorder '1';
188         comment 'number of DC connection requests, by GNB and PCI';
189 }
190 PARAM{ window uint; }
191 SELECT ($window*(TB+1))/1000 as TS, GNB_ID, physCellId,
192         $window/1000.0 as measurementInterval, // standard_name
193         COUNT(*) as count_ue_connects
194 FROM dc_events_pci
195 WHERE event_type = 1
196 GROUP BY TB, gnb_id as GNB_ID, physCellId
197 ;
198
199 DEFINE{ query_name 'mc_connects_cnt_gtp_teid'; 
200         max_lfta_disorder '1'; max_hfta_disorder '1';
201         comment 'number of DC connection requests by UE';
202 }
203 PARAM{ window uint; }
204 SELECT ($window*(TB+1))/1000 as TS, GNB_ID, gTP_TEID,
205         $window/1000.0 as measurementInterval, // standard_name
206         COUNT(*) as count_ue_connects
207 FROM dc_events_gtp_teid
208 WHERE event_type = 1
209 GROUP BY  TB, gnb_id as GNB_ID, gTP_TEID
210 ;
211
212 DEFINE{ query_name 'mc_disconnects_cnt'; 
213         max_lfta_disorder '1'; max_hfta_disorder '1';
214         comment 'number of DC connection releases';
215 }
216 PARAM{ window uint; }
217 SELECT ($window*(TB+1))/1000 as TS, GNB_ID,
218          $window/1000.0 as measurementInterval, // standard_name
219          COUNT(*) as count_ue_disconnects
220 FROM dc_events
221 WHERE event_type = 0
222 GROUP BY timestamp / $window as TB, gnb_id as GNB_ID
223 ;
224
225 DEFINE{ query_name 'mc_unique_ues'; 
226         max_lfta_disorder '1'; max_hfta_disorder '1';
227 }
228 PARAM{ window uint; }
229 SELECT TB, UE_ID, GNB_ID
230 FROM dc_events
231 GROUP BY timestamp / $window as TB, gUE_ID as UE_ID, gnb_id as GNB_ID
232 ;
233
234 DEFINE{ query_name 'mc_unique_ues_pci'; 
235         max_lfta_disorder '1'; max_hfta_disorder '1';
236 }
237 PARAM{ window uint; }
238 SELECT TB, UE_ID, GNB_ID, physCellId
239 FROM dc_events_pci
240 GROUP BY  TB,
241         gUE_ID as UE_ID, gnb_id as GNB_ID, physCellId
242 ;
243
244
245
246 DEFINE{ query_name 'mc_unique_ue_cnt'; 
247         max_lfta_disorder '1'; max_hfta_disorder '1';
248         comment 'Number of distinct UEs making a DC request or release';
249 }
250 PARAM{ window uint; } 
251 SELECT ($window*(TB+1))/1000 as TS, GNB_ID,
252          $window/1000.0 as measurementInterval, // standard_name
253          COUNT(*) as count_unique_ue
254 FROM mc_unique_ues
255 GROUP BY TB, GNB_ID
256 ;
257
258
259 DEFINE{ query_name 'mc_unique_ue_pci_cnt'; 
260         max_lfta_disorder '1'; max_hfta_disorder '1';
261         comment 'Number of distinct UEs making a DC request or release by pci';
262 }
263 PARAM{ window uint; } 
264 SELECT ($window*(TB+1))/1000 as TS, GNB_ID, physCellId,
265          $window/1000.0 as measurementInterval, // standard_name
266          COUNT(*) as count_unique_ue
267 FROM mc_unique_ues_pci
268 GROUP BY TB, GNB_ID, physCellId
269
270