Support for additional 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
44
45
46 DEFINE{ query_name 'mc_connected_ues'; 
47         max_lfta_disorder '1'; max_hfta_disorder '1';
48 }
49 PARAM{ window uint; }
50 SELECT TB, UE_ID, GNB_ID,
51         ((TB+1)*$window-LAST(timestamp))/1000.0 as connected_time
52 FROM dc_events
53 GROUP BY timestamp / $window as TB, gUE_ID as UE_ID, gnb_id as GNB_ID
54 HAVING LAST(event_type) = 1
55 CLOSING_WHEN LAST(event_type) = 0 OR
56                 ((TB+1)*$window-LAST(timestamp))/1000.0 >= 3600
57 ;
58
59 DEFINE{ query_name 'mc_connected_cnt'; 
60         max_lfta_disorder '1'; max_hfta_disorder '1';
61         comment 'Number of dual connected users';
62 }
63 PARAM{ window uint; }
64 SELECT ($window*(TB+1))/1000 as TS, GNB_ID, 
65                 $window/1000.0 as measurementInterval, // standard_name
66       COUNT(*) as count_connected_ue
67 FROM mc_connected_ues
68 GROUP BY TB,  GNB_ID
69 ;
70
71 DEFINE{ query_name 'mc_disconnected_ues'; 
72         max_lfta_disorder '1'; max_hfta_disorder '1';
73 }
74 PARAM{ window uint; }
75 SELECT TB_1000, UE_ID, GNB_ID,
76         UINT((LAST(timestamp) - FIRST(timestamp))) as connected_time
77 FROM dc_events
78 GROUP BY timestamp / 1000  as TB_1000, gUE_ID as UE_ID, gnb_id as GNB_ID
79 HAVING LAST(event_type) = 0
80 CLOSING_WHEN LAST(event_type) = 0 OR
81                 ((TB_1000+1)*1000-LAST(timestamp))/1000.0 >= 3600
82 ;
83
84
85
86 DEFINE{ query_name 'mc_connection_stats'; 
87         max_lfta_disorder '1'; max_hfta_disorder '1';
88         comment 'statistics about the length of dual connected sessions by gnb';
89 }
90 PARAM{ window uint; }
91 SELECT ($window*(TB+1))/1000 as TS, GNB_ID,
92         $window/1000.0 as measurementInterval, // standard_name
93         MIN(connected_time)/1000.0 as min_connected_time,
94         MAX(connected_time)/1000.0 as max_connected_time,
95         AVG(connected_time)/1000.0 as avg_connected_time,
96         quantile_of(connected_time, .05)/1000.0 as pctl_05_connected_time,
97         quantile_of(connected_time, .95)/1000.0 as pctl_95_connected_time,
98         sqrt(
99                 sum((connected_time/1000.0)*(connected_time/1000.0)) - sum(connected_time/1000.0)*sum(connected_time/1000.0)/count(*)
100         ) / count(*) as stddev_connected_time
101 FROM mc_disconnected_ues
102 GROUP BY (TB_1000 * 1000) / $window as TB, GNB_ID
103 ;
104
105 DEFINE{ query_name 'mc_disconnected_gtp_teids'; 
106         max_lfta_disorder '1'; max_hfta_disorder '1';
107 }
108 PARAM{ window uint; }
109 Select m.TB, m.gTP_TEID, d.GNB_ID, d.connected_time
110 LEFT_OUTER_JOIN from mc_disconnected_ues d, gnb_ueid_teid_map m
111 where d.GNB_ID=m.GNB_ID and d.UE_ID=m.id_SgNB_UE_X2AP_ID and
112         (d.TB_1000 * 1000) / $window = m.TB
113 ;
114
115 DEFINE{ query_name 'mc_connection_stats_gtp_teid'; 
116         max_lfta_disorder '1'; max_hfta_disorder '1';
117         comment 'statistics about the length of dual connected sessions, by gtp_teid';
118 }
119 PARAM{ window uint; }
120 SELECT ($window*(TB+1))/1000 as TS, GNB_ID, gTP_TEID,
121         $window/1000.0 as measurementInterval, // standard_name
122         MIN(connected_time)/1000.0 as min_connected_time,
123         MAX(connected_time)/1000.0 as max_connected_time,
124         AVG(connected_time)/1000.0 as avg_connected_time,
125         quantile_of(connected_time, .05)/1000.0 as pctl_05_connected_time,
126         quantile_of(connected_time, .95)/1000.0 as pctl_95_connected_time,
127         sqrt(
128                 sum((connected_time/1000.0)*(connected_time/1000.0)) - sum(connected_time/1000.0)*sum(connected_time/1000.0)/count(*)
129         ) / count(*) as stddev_connected_time
130 FROM mc_disconnected_gtp_teids
131 GROUP BY TB, GNB_ID, gTP_TEID
132 ;
133
134
135
136
137 DEFINE{ query_name 'mc_connects_cnt'; 
138         max_lfta_disorder '1'; max_hfta_disorder '1';
139         comment 'number of DC connection requests, by GNB';
140 }
141 PARAM{ window uint; }
142 SELECT ($window*(TB+1))/1000 as TS, GNB_ID,
143         $window/1000.0 as measurementInterval, // standard_name
144         COUNT(*) as count_ue_connects
145 FROM dc_events
146 WHERE event_type = 1
147 GROUP BY timestamp / $window as TB, gnb_id as GNB_ID
148 ;
149
150 DEFINE{ query_name 'mc_connects_cnt_gtp_teid'; 
151         max_lfta_disorder '1'; max_hfta_disorder '1';
152         comment 'number of DC connection requests by UE';
153 }
154 PARAM{ window uint; }
155 SELECT ($window*(TB+1))/1000 as TS, GNB_ID, gTP_TEID,
156         $window/1000.0 as measurementInterval, // standard_name
157         COUNT(*) as count_ue_connects
158 FROM dc_events_gtp_teid
159 WHERE event_type = 1
160 GROUP BY  TB, gnb_id as GNB_ID, gTP_TEID
161 ;
162
163 DEFINE{ query_name 'mc_disconnects_cnt'; 
164         max_lfta_disorder '1'; max_hfta_disorder '1';
165         comment 'number of DC connection releases';
166 }
167 PARAM{ window uint; }
168 SELECT ($window*(TB+1))/1000 as TS, GNB_ID,
169          $window/1000.0 as measurementInterval, // standard_name
170          COUNT(*) as count_ue_disconnects
171 FROM dc_events
172 WHERE event_type = 0
173 GROUP BY timestamp / $window as TB, gnb_id as GNB_ID
174 ;
175
176 DEFINE{ query_name 'mc_unique_ues'; 
177         max_lfta_disorder '1'; max_hfta_disorder '1';
178 }
179 PARAM{ window uint; }
180 SELECT TB, UE_ID, GNB_ID
181 FROM dc_events
182 GROUP BY timestamp / $window as TB, gUE_ID as UE_ID, gnb_id as GNB_ID
183 ;
184
185 DEFINE{ query_name 'mc_unique_ue_cnt'; 
186         max_lfta_disorder '1'; max_hfta_disorder '1';
187         comment 'Number of distinct UEs making a DC request or release';
188 }
189 PARAM{ window uint; } 
190 SELECT ($window*(TB+1))/1000 as TS, GNB_ID,
191          $window/1000.0 as measurementInterval, // standard_name
192          COUNT(*) as count_unique_ue
193 FROM mc_unique_ues
194 GROUP BY TB, GNB_ID
195
196
197