Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions context/amf_ran.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ func (ran *AmfRan) Remove() {
}
} else {
AMF_Self().DeleteAmfRan(ran.Conn)
count := 0
AMF_Self().AmfRanPool.Range(func(key, value interface{}) bool {
count++
return true
})
metrics.SetNoOfActiveGnbStats(uint64(count))
}
}

Expand Down
6 changes: 6 additions & 0 deletions context/amf_ue.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,12 @@ func (ue *AmfUe) Remove() {

if len(ue.Supi) > 0 {
AMF_Self().UePool.Delete(ue.Supi)
count := 0
AMF_Self().UePool.Range(func(key, value interface{}) bool {
count++
return true
})
metrics.SetNoOfActiveSubStats(uint64(count))
}
if ue.EventChannel != nil {
ue.EventChannel.Event <- "quit"
Expand Down
7 changes: 7 additions & 0 deletions gmm/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,12 @@ func HandleInitialRegistration(ue *context.AmfUe, anType models.AccessType) erro
gmm_message.SendRegistrationAccept(ue, anType, nil, nil, nil, nil, nil)
metrics.IncrementUeRegStats(context.AMF_Self().NfId, "success")
metrics.SetNoOfUeConnectionStats(context.AMF_Self().NfId, ue.Suci, ue.Guti, 1)
count := 0
context.AMF_Self().UePool.Range(func(key, value interface{}) bool {
count++
return true
})
metrics.SetNoOfActiveSubStats(uint64(count))
} else {
// TS 23.502 4.12.2.2 10a ~ 13: if non-3gpp, AMF should send initial context setup request to N3IWF first,
// and send registration accept after receiving initial context setup response
Expand Down Expand Up @@ -1636,6 +1642,7 @@ func AuthenticationProcedure(ue *context.AmfUe, accessType models.AccessType) (b
}
ue.GmmLog.Infoln("ngKSI after 5G-AKA:", ue.NgKsi.Ksi)
gmm_message.SendAuthenticationRequest(ue.RanUe[accessType])
metrics.IncrementAuthReqStats(ue.Suci)
return false, nil
}

Expand Down
60 changes: 51 additions & 9 deletions metrics/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ type AmfStats struct {
n2HandoverFail *prometheus.CounterVec
nfNonReachable *prometheus.CounterVec
noOfUeConnect *prometheus.GaugeVec
noOfGnbConnect *prometheus.GaugeVec
noOfActiveSub prometheus.Gauge
noOfActiveGnb prometheus.Gauge
gnbConnect *prometheus.CounterVec
AuthRequestTotal *prometheus.CounterVec
}

var amfStats *AmfStats
Expand Down Expand Up @@ -100,10 +103,25 @@ func initAmfStats() *AmfStats {
Help: "UE connections total",
}, []string{"id", "supi", "guti"}),

noOfGnbConnect: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "gnb_connected_total",
Help: "GNB connections total",
}, []string{"id", "gnb_id", "gnb_ip"}),
noOfActiveSub: prometheus.NewGauge(prometheus.GaugeOpts{
Name: "amf_active_subscribers",
Help: "current number of active subscribers in the core",
}),

noOfActiveGnb: prometheus.NewGauge(prometheus.GaugeOpts{
Name: "amf_active_gnb",
Help: "current number of active gNB's in the core",
}),

gnbConnect: prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "amf_gnb_connected_total",
Help: "Counter of total gNB connections",
}, []string{"gnb_id", "gnb_ip", "name"}),

AuthRequestTotal: prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "amf_auth_request_total",
Help: "Counter of total authentication request send",
}, []string{"supi"}),
}
}

Expand Down Expand Up @@ -146,7 +164,16 @@ func (ps *AmfStats) register() error {
if err := prometheus.Register(ps.noOfUeConnect); err != nil {
return err
}
if err := prometheus.Register(ps.noOfGnbConnect); err != nil {
if err := prometheus.Register(ps.noOfActiveSub); err != nil {
return err
}
if err := prometheus.Register(ps.noOfActiveGnb); err != nil {
return err
}
if err := prometheus.Register(ps.gnbConnect); err != nil {
return err
}
if err := prometheus.Register(ps.AuthRequestTotal); err != nil {
return err
}
return nil
Expand Down Expand Up @@ -228,7 +255,22 @@ func SetNoOfUeConnectionStats(id, suci, guti string, count uint64) {
amfStats.noOfUeConnect.WithLabelValues(id, suci, guti).Set(float64(count))
}

// SetNoOfGnbConnectionStats maintains total gNB connections info
func SetNoOfGnbConnectionStats(id, gnbid, gnbip string, count uint64) {
amfStats.noOfGnbConnect.WithLabelValues(id, gnbid, gnbip).Set(float64(count))
// SetNoOfActiveSubStats maintains total active subscribers info
func SetNoOfActiveSubStats(count uint64) {
amfStats.noOfActiveSub.Set(float64(count))
}

// SetNoOfActiveGnbStats maintains total active subscribers info
func SetNoOfActiveGnbStats(count uint64) {
amfStats.noOfActiveGnb.Set(float64(count))
}

// IncrementGnbConnStats maintains gnb connection level stats
func IncrementGnbConnStats(gnbid, gnbip, name string) {
amfStats.gnbConnect.WithLabelValues(gnbid, gnbip, name).Inc()
}

// IncrementAuthReqStats maintains gnb connection level stats
func IncrementAuthReqStats(supi string) {
amfStats.AuthRequestTotal.WithLabelValues(supi).Inc()
}
9 changes: 7 additions & 2 deletions ngap/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,13 @@ func HandleNGSetupRequest(ran *context.AmfRan, message *ngapType.NGAPPDU) {
}
if cause.Present == ngapType.CausePresentNothing {
ngap_message.SendNGSetupResponse(ran)
metrics.SetNoOfGnbConnectionStats(context.AMF_Self().NfId, ran.GnbId, ran.GnbIp, 1)
count := 0
context.AMF_Self().AmfRanPool.Range(func(key, value interface{}) bool {
count++
return true
})
metrics.SetNoOfActiveGnbStats(uint64(count))
metrics.IncrementGnbConnStats(ran.GnbId, ran.GnbIp, ran.Name)
// send nf(gnb) status notification
gnbStatus := mi.MetricEvent{
EventType: mi.CNfStatusEvt,
Expand All @@ -812,7 +818,6 @@ func HandleNGSetupRequest(ran *context.AmfRan, message *ngapType.NGAPPDU) {
}
} else {
ngap_message.SendNGSetupFailure(ran, cause)
metrics.SetNoOfGnbConnectionStats(context.AMF_Self().NfId, ran.GnbId, ran.GnbIp, 0)
}
}

Expand Down
Loading