Change RMR version to 4.0.5, start listener in background mode at container startup
[ric-app/mc.git] / mc-core / mc / queries / throughput.gsql
1 DEFINE{query_name 'throughput_ue';
2         extra_keys 'TS';
3         max_lfta_disorder '1'; max_hfta_disorder '1';
4         comment 'throughput experienced by UE over a measurement interval.   *Active* throughput is throughput while actively downloading, *average* averages bytes transfered over the measurement interval';
5 }
6 PARAM{ window uint; }
7 select ($window*(TB+1))/1000 as TS, e_RAB_ID, UE_ID, GNB_ID,
8        $window/1000.0 as measurementInterval,
9
10                 sum(usageCountDL) / UMAX( sum( endian_swap_ui(UINT(endTimeStamp)) - endian_swap_ui(UINT(startTimeStamp))), 1)  as active_throughput,
11
12                 sum(usageCountDL) / UMAX( max( endian_swap_ui(UINT(endTimeStamp))) - min(endian_swap_ui(UINT(startTimeStamp))), 1)  as average_throughput,
13
14                 min( usageCountDL / UMAX( endian_swap_ui(UINT(endTimeStamp)) - endian_swap_ui(UINT(startTimeStamp)), 1) ) as min_throughput,
15
16                 max( usageCountDL / UMAX( endian_swap_ui(UINT(endTimeStamp)) - endian_swap_ui(UINT(startTimeStamp)), 1) ) as max_throughput
17 from RATDATAUSAGE.rat_data_usage
18 group by e_RAB_ID, id_SgNB_UE_X2AP_ID as UE_ID, gnb_id as GNB_ID,
19         timestamp_ms/$window as TB
20 ;
21
22 DEFINE{query_name 'prelim_throughput_gtp_teid';
23         extra_keys 'TB';
24         max_lfta_disorder '1'; max_hfta_disorder '1';
25         comment 'pre-aggregation to get per-teid throughput';
26 }
27 PARAM{ window uint; }
28 select TB, GNB_UE_ID, GNB_ID, e_RAB_ID,
29         sum(usageCountDL)  as sum_usageCountDL,
30         sum( endian_swap_ui(UINT(endTimeStamp)) - endian_swap_ui(UINT(startTimeStamp)))  as sum_duration,
31          max( endian_swap_ui(UINT(endTimeStamp))) as max_end_ts,
32          min(endian_swap_ui(UINT(startTimeStamp))) as min_start_ts,
33         min( usageCountDL / UMAX( endian_swap_ui(UINT(endTimeStamp)) - endian_swap_ui(UINT(startTimeStamp)), 1) ) as min_throughput,
34         max( usageCountDL / UMAX( endian_swap_ui(UINT(endTimeStamp)) - endian_swap_ui(UINT(startTimeStamp)), 1) ) as max_throughput
35 from RATDATAUSAGE.rat_data_usage
36 group by id_SgNB_UE_X2AP_ID as GNB_UE_ID, gnb_id as GNB_ID, e_RAB_ID, timestamp_ms/$window as TB
37 ;
38
39 DEFINE{query_name 'throughput_ue_gtp_teid_join';
40         max_lfta_disorder '1'; max_hfta_disorder '1';
41         comment 'Join throughput_ue with gnb_ueid_teid_map to get the gtp_teid, a followup query will reaggregate';
42 }
43 PARAM{ window uint; }
44 select T.TB, T.GNB_UE_ID, T.GNB_ID, T.e_RAB_ID, M.gTP_TEID,
45         T.sum_usageCountDL, T.sum_duration, T.max_end_ts, T.min_start_ts,
46         T.min_throughput, max_throughput
47 INNER_JOIN from prelim_throughput_gtp_teid T, gnb_ueid_teid_map M
48 Where T.GNB_ID=M.GNB_ID and T.GNB_UE_ID=M.id_SgNB_UE_X2AP_ID and T.TB=M.TB
49 ;
50
51 DEFINE{query_name 'throughput_gtp_teid';
52         extra_keys 'TS';
53         max_lfta_disorder '1'; max_hfta_disorder '1';
54         comment 'throughput experienced by UE, as determined by the gtp_teid, over a measurement interval.   *Active* throughput is throughput while actively downloading, *average* averages bytes transfered over the measurement interval';
55 }
56 PARAM{ window uint; }
57 select ($window*(TB+1))/1000 as TS, gTP_TEID, GNB_ID,
58        $window/1000.0 as measurementInterval,
59                 sum(sum_usageCountDL) / UMAX( sum(sum_duration), 1)  as active_throughput,
60                 sum(sum_usageCountDL) / UMAX( max(max_end_ts) - min(min_start_ts), 1)  as average_throughput,
61                 min( min_throughput ) as min_throughput,
62                 max( max_throughput ) as max_throughput
63 from throughput_ue_gtp_teid_join
64 group by  GNB_ID, gTP_TEID, TB
65 ;
66
67 DEFINE{query_name 'throughput_gtp_teid_bearer';
68         extra_keys 'TS';
69         max_lfta_disorder '1'; max_hfta_disorder '1';
70         comment 'throughput experienced by UE, as determined by the gtp_teid, for a bearer (eRAB_ID) over a measurement interval.   *Active* throughput is throughput while actively downloading, *average* averages bytes transfered over the measurement interval';
71 }
72 PARAM{ window uint; }
73 select ($window*(TB+1))/1000 as TS, gTP_TEID, GNB_ID, e_RAB_ID,
74        $window/1000.0 as measurementInterval,
75                 sum(sum_usageCountDL) / UMAX( sum(sum_duration), 1)  as active_throughput,
76                 sum(sum_usageCountDL) / UMAX( max(max_end_ts) - min(min_start_ts), 1)  as average_throughput,
77                 min( min_throughput ) as min_throughput,
78                 max( max_throughput ) as max_throughput
79 from throughput_ue_gtp_teid_join
80 group by  GNB_ID, gTP_TEID, e_RAB_ID, TB
81 ;
82
83 // -----------------------------------------
84
85 DEFINE{query_name 'add_req_event';
86         max_lfta_disorder '1'; max_hfta_disorder '1';
87         comment 'addition_request event, for merging into qci-arp map';
88 }
89 PARAM{ window uint;}
90 Select timestamp_ms, id_MeNB_UE_X2AP_ID, LLONG(0) as id_SgNB_UE_X2AP_ID, gnb_id,
91         qCI,  priorityLevel as ARP, 0 as event_type
92 from SGNB_ADDITION_REQ.sgnb_addreq_for_ue_bearers R
93 ;
94
95 DEFINE{query_name 'add_req_ack_event';
96         max_lfta_disorder '1'; max_hfta_disorder '1';
97         comment 'addition_request_acknowledge event, for merging into qci-arp map';
98 }
99 PARAM{ window uint;}
100 Select timestamp_ms, id_MeNB_UE_X2AP_ID, id_SgNB_UE_X2AP_ID, gnb_id,
101         LLONG(0) as qCI,  LLONG(0) as ARP, 1 as event_type
102 From SGNB_ADDITION_REQ_ACK.eRABs_acked_for_admit_for_ue A
103 ;
104
105 DEFINE{query_name 'add_req_events';
106         max_lfta_disorder '1'; max_hfta_disorder '1';
107         comment 'addition_request / acknowledge events';
108 }
109 PARAM{ window uint;}
110 Merge R.timestamp_ms : A.timestamp_ms
111 From add_req_event R, add_req_ack_event A
112 ;
113
114 DEFINE{query_name 'gnb_ueid_qci_arp_map';
115         max_lfta_disorder '1'; max_hfta_disorder '1';
116         comment 'Output the last known map from (gnb, gnb_ueid) to (qci, arp)';
117 }
118 PARAM{ window uint;}
119 Select TB, GNB_ID, id_MeNB_UE_X2AP_ID, LAST(id_SgNB_UE_X2AP_ID) as id_SgNB_UE_X2AP_ID,
120         FIRST(qCI) as qCI, FIRST(ARP) as ARP
121 From add_req_events
122 GROUP BY timestamp_ms / $window as TB, id_MeNB_UE_X2AP_ID, gnb_id as GNB_ID
123 Having LAST(event_type) = 1
124 CLOSING_WHEN ((TB+1)*$window-LAST(timestamp_ms))/1000.0 >= 3600
125 ;
126
127
128 -- DEFINE{query_name 'gueid_to_qciarp_join';
129 --      max_lfta_disorder '1'; max_hfta_disorder '1';
130 --      comment 'get gnb_ueid to qci,arp mapping, gnb_ueid is in sgnb addition request acknowledge, qci,arp is in sgnb addition request';
131 -- }
132 -- PARAM{ window uint;}
133 -- Select A.timestamp_ms/$window as TB,
134 --      non_temporal(A.timestamp_ms) as timestamp_ms,
135 --      R.id_MeNB_UE_X2AP_ID, A.id_SgNB_UE_X2AP_ID, A.gnb_id,
136 --      R.qCI, R.priorityLevel as ARP
137 -- INNER_JOIN from SGNB_ADDITION_REQ.sgnb_addreq_for_ue_bearers R,
138 --               SGNB_ADDITION_REQ_ACK.eRABs_acked_for_admit_for_ue A
139 -- Where A.timestamp_ms/$window = R.timestamp_ms/$window and
140 --      A.gnb_id = R.gnb_id and A.id_MeNB_UE_X2AP_ID = R.id_MeNB_UE_X2AP_ID
141 -- --   AND R.PCI = A.PCI
142 -- ;
143
144 -- DEFINE{query_name 'gnb_ueid_qci_arp_map';
145 --      max_lfta_disorder '1'; max_hfta_disorder '1';
146 --      comment 'Output the last known map from (gnb, gnb_ueid) to (qci, arp)';
147 -- }
148 -- PARAM{ window uint;}
149 -- Select TB, GNB_ID, id_SgNB_UE_X2AP_ID, LAST(qCI) as qCI, LAST(ARP) as ARP
150 -- from gueid_to_qciarp_join
151 -- --from SGNB_ADDITION_REQ_ACK.eRABs_acked_for_admit_for_ue
152 -- group by TB, gnb_id as GNB_ID, id_SgNB_UE_X2AP_ID
153 -- CLOSING_WHEN ((TB+1)*$window-LAST(timestamp_ms))/1000.0 >= 3600
154 -- ;
155
156 DEFINE{query_name 'throughput_ue_userclass_join';
157         max_lfta_disorder '1'; max_hfta_disorder '1';
158         comment 'Join throughput_ue with gnb_ueid_teid_map to get the gtp_tied, a followup query will reaggregate';
159 }
160 PARAM{ window uint; }
161 select T.TB, T.GNB_UE_ID, T.GNB_ID,
162         EQ(qCI, 9)*EQ(M.ARP, 15) + 2*EQ(qCI, 8)*EQ(M.ARP, 15) as class,
163         T.sum_usageCountDL, T.sum_duration, T.max_end_ts, T.min_start_ts,
164         T.min_throughput, max_throughput
165 INNER_JOIN from prelim_throughput_gtp_teid T, gnb_ueid_qci_arp_map M
166 Where T.GNB_ID=M.GNB_ID and T.GNB_UE_ID=M.id_SgNB_UE_X2AP_ID
167         and T.TB=M.TB
168 ;
169
170 DEFINE{query_name 'throughput_userclass';
171         extra_keys 'TS';
172         max_lfta_disorder '1'; max_hfta_disorder '1';
173         comment 'throughput experienced by UE, rolled up into user classes, over a measurement interval.  Class A (qci=9, arp=15) is class=1 and Class B  (qci=8, arp=15) is class=2.   *Active* throughput is throughput while actively downloading, *average* averages bytes transfered over the measurement interval';
174 }
175 PARAM{ window uint; }
176 select ($window*(TB+1))/1000 as TS, GNB_ID, class as CLASS,
177        $window/1000.0 as measurementInterval,
178                 sum(sum_usageCountDL) / UMAX( sum(sum_duration), 1)  as active_throughput,
179                 sum(sum_usageCountDL) / UMAX( max(max_end_ts) - min(min_start_ts), 1)  as average_throughput,
180                 min( min_throughput ) as min_throughput,
181                 max( max_throughput ) as max_throughput
182 from throughput_ue_userclass_join
183 //where class>0
184 group by  TB, GNB_ID, class
185 ;
186
187
188
189 DEFINE{query_name 'throughput_rollup';
190         extra_keys 'TS';
191         max_lfta_disorder '1'; max_hfta_disorder '1';
192         comment 'statistics on the per-UE throughput';
193 }
194 PARAM{ window uint; }
195 select TS, e_RAB_ID, GNB_ID,
196        $window/1000.0 as measurementInterval,
197         count(*) as count_ues,
198         quantile_of( UINT(average_throughput), .05) as average_throughput_percentile_05,
199         quantile_of( UINT(average_throughput), .50) as average_throughput_percentile_50,
200         avg( average_throughput) as average_average_throughput,
201         quantile_of( UINT(average_throughput), .95) as average_throughput_percentile_95,
202         quantile_of( UINT(active_throughput), .05) as active_throughput_percentile_05,
203         quantile_of( UINT(active_throughput), .50) as active_throughput_percentile_50,
204         avg( active_throughput) as average_active_throughput,
205         quantile_of( UINT(active_throughput), .95) as active_throughput_percentile_95
206 from throughput_ue
207 group by TS, e_RAB_ID, GNB_ID
208 ;
209
210 DEFINE{query_name 'throughput_gnb';
211         max_lfta_disorder '1'; max_hfta_disorder '1';
212         comment 'throughput experienced by a GNB over a measurement interval.   *Active* throughput is throughput while actively downloading, *average* averages bytes transfered over the measurement interval';
213 }
214 PARAM{ window uint; }
215 select ($window*(TB+1))/1000 as TS, e_RAB_ID, GNB_ID,
216        $window/1000.0 as measurementInterval,
217
218                 sum(usageCountDL) / UMAX( sum( endian_swap_ui(UINT(endTimeStamp)) - endian_swap_ui(UINT(startTimeStamp))), 1)  as active_throughput,
219
220                 sum(usageCountDL) / UMAX( max( endian_swap_ui(UINT(endTimeStamp))) - min(endian_swap_ui(UINT(startTimeStamp))), 1)  as average_throughput,
221
222                 min( usageCountDL / UMAX( endian_swap_ui(UINT(endTimeStamp)) - endian_swap_ui(UINT(startTimeStamp)), 1) ) as min_throughput,
223
224                 max( usageCountDL / UMAX( endian_swap_ui(UINT(endTimeStamp)) - endian_swap_ui(UINT(startTimeStamp)), 1) ) as max_throughput,
225
226                 quantile_of( UINT( (usageCountDL) / UMAX( endian_swap_ui(UINT(endTimeStamp)) - endian_swap_ui(UINT(startTimeStamp)), 1)), .05) as active_throughput_percentile_05,
227
228                 quantile_of( UINT( (usageCountDL) / UMAX( endian_swap_ui(UINT(endTimeStamp)) - endian_swap_ui(UINT(startTimeStamp)), 1)), .95) as active_throughput_percentile_95
229
230 from RATDATAUSAGE.rat_data_usage
231 group by e_RAB_ID, gnb_id as GNB_ID, timestamp_ms/$window as TB
232
233