Support for additional NR metrics
[ric-app/mc.git] / mc-core / mc / queries / handovers.gsql
1 DEFINE{query_name 'handovers_join';
2         max_lfta_disorder '1'; max_hfta_disorder '1';
3 }
4 PARAM{ window uint; }
5 select r.timestamp_ms/$window as TB,
6         non_temporal(g.timestamp_ms) as timestamp_ms,
7         r.id_MeNB_UE_X2AP_ID,
8         r.id_SgNB_UE_X2AP_ID, g.gTP_TEID, g.gnb_id
9 INNER_JOIN from SGNB_ADDITION_REQ.sgnb_addreq_gtp_teid g,
10         RECONCOMPLETE.reconfig_success r
11 where 
12  r.id_MeNB_UE_X2AP_ID = g.id_MeNB_UE_X2AP_ID
13 and r.timestamp_ms/$window = g.timestamp_ms/$window
14 ;
15
16 DEFINE{ query_name 'handovers_gnb'; 
17         max_lfta_disorder '1'; max_hfta_disorder '1';
18         comment 'Number of handovers on a per-gtp_teid basis';
19 }
20 PARAM{ window uint;}
21
22 //      Need to correlate with reconfiguration complete
23 //              n_handovers, n_pingpong
24 //      From raw sgnb_addreq_gtp_teid feed
25 //              n_pingpong_attempts 
26 Select ($window*(TB+1))/1000 as TS,
27         $window/1000.0 as measurementInterval,
28         gTP_TEID as GTP_TEID, GNB_ID,
29         count(*) as total_addition_requests,
30         count_diff(gnb_id) - 1 as n_handovers,
31         count(*) - count_diff(gnb_id) as n_ping_pong
32 from handovers_join
33 group by TB, gTP_TEID, gnb_id as GNB_ID
34 ;
35
36 DEFINE{ query_name 'distinct_users'; 
37         max_lfta_disorder '1'; max_hfta_disorder '1';
38         comment 'Number of users based on distinct gTP_TEIDs seen';
39 }
40 PARAM{ window uint;}
41 Select ($window*(tb+1))/1000 as TS, $window/1000.0 as measurementInterval,
42         gnb_id as GNB_ID,
43         count(*) as num_users
44 from SGNB_ADDITION_REQ.sgnb_addreq_gtp_teid
45 group by timestamp_ms/$window as tb, gnb_id
46 ;
47
48 DEFINE{query_name 'gnb_ueid_teid_map';
49         max_lfta_disorder '1'; max_hfta_disorder '1';
50         comment 'Output the last known map from (gnb, gnb_ueid) to gtp_teid';
51 }
52 PARAM{ window uint;}
53 Select TB, GNB_ID, id_SgNB_UE_X2AP_ID, id_MeNB_UE_X2AP_ID,
54         LAST(gTP_TEID) as gTP_TEID
55 from handovers_join
56 group by TB, gnb_id as GNB_ID, id_SgNB_UE_X2AP_ID, id_MeNB_UE_X2AP_ID
57 CLOSING_WHEN ((TB+1)*$window-LAST(timestamp_ms))/1000.0 >= 3600
58 ;
59
60 -------------------------------------------
61 -- Handover counts
62
63 DEFINE{query_name 'modification_confirm_count';
64         max_lfta_disorder '1'; max_hfta_disorder '1';
65         comment 'Number of sgnb modification confirms, by UE, part of handover count';
66 }
67 PARAM{ window uint;}
68 Select TB, GNB_ID, id_SgNB_UE_X2AP_ID, id_MeNB_UE_X2AP_ID,
69         count(*) as cnt
70 from SGNBMODCONF.sgnb_mod_conf 
71 group by timestamp_ms/$window as TB, gnb_id as GNB_ID,
72         id_SgNB_UE_X2AP_ID, id_MeNB_UE_X2AP_ID
73 ;
74
75 DEFINE{query_name 'modification_req_ack_count';
76         max_lfta_disorder '1'; max_hfta_disorder '1';
77         comment 'Number of sgnb modification request acknowledgements, by UE, part of handover count';
78 }
79 PARAM{ window uint;}
80 Select TB, GNB_ID, id_SgNB_UE_X2AP_ID, id_MeNB_UE_X2AP_ID,
81         count(*) as cnt
82 from SGNBMODREQACK.sgnb_mod_req_ack 
83 group by timestamp_ms/$window as TB, gnb_id as GNB_ID,
84         id_SgNB_UE_X2AP_ID, id_MeNB_UE_X2AP_ID
85 ;
86
87 DEFINE{query_name 'ho_count_events';}
88 PARAM{ window uint; }
89 merge p1.TB : p2.TB
90 from modification_confirm_count p1, modification_req_ack_count p2
91 ;
92
93 DEFINE{query_name 'ho_count_events_gtp_teid';
94         max_lfta_disorder '1'; max_hfta_disorder '1';
95         comment 'Label ho count events with UE (gtp_teid)';
96 }
97 PARAM{ window uint;}
98 Select h.TB, h.GNB_ID, m.gTP_TEID, cnt
99 LEFT_OUTER_JOIN from ho_count_events h, gnb_ueid_teid_map m
100 where h.TB=m.TB and h.id_MeNB_UE_X2AP_ID=m.id_MeNB_UE_X2AP_ID
101         and h.GNB_ID=m.GNB_ID
102 ;
103
104 DEFINE{query_name 'ho_counts_gtp_teid';
105         max_lfta_disorder '1'; max_hfta_disorder '1';
106         comment 'Number of handovers, by UE (gTP_TEID)';
107 }
108 PARAM{ window uint;}
109 Select ($window*(TB+1))/1000 as TS, GNB_ID, gTP_TEID,
110         $window/1000.0 as measurementInterval,
111         sum(cnt) as n_handovers
112 from ho_count_events_gtp_teid
113 group by TB, GNB_ID, gTP_TEID
114
115