From fe6632333af0195cdb22aa3edf6ca4e41cbfe28b Mon Sep 17 00:00:00 2001 From: "Marikkannu, Suresh" Date: Fri, 9 May 2025 02:30:21 -0700 Subject: [PATCH 1/5] Update metricfunc to provide misbehaving subscriber data to promethues Signed-off-by: Marikkannu, Suresh --- controller/controller.go | 4 ++++ internal/promclient/promclient.go | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/controller/controller.go b/controller/controller.go index 60f7527..02e5b86 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -17,6 +17,7 @@ import ( "strings" "time" + "github.com/omec-project/metricfunc/internal/promclient" "github.com/omec-project/metricfunc/config" "github.com/omec-project/metricfunc/internal/metricdata" "github.com/omec-project/metricfunc/logger" @@ -366,6 +367,7 @@ func RogueIPHandler(rogueIPChannel chan RogueIPs) { continue } logger.ControllerLog.Infof("subscriber Imsi [%v] of the IP: [%v]", subscriberInfo.Imsi, ipaddr) + promclient.PushViolSubData(subscriberInfo.Imsi, ipaddr, "Active") // get enterprises or targets from ROC targets := rocClient.GetTargets() @@ -373,6 +375,8 @@ func RogueIPHandler(rogueIPChannel chan RogueIPs) { logger.ControllerLog.Errorln("get targets returns nil") } else { // get siteinfo from ROC + promclient.DeleteViolSubData(subscriberInfo.Imsi, ipaddr, "Active") + promclient.PushViolSubData(subscriberInfo.Imsi, ipaddr, "Resolved") rocClient.DisableSimcard(targets, subscriberInfo.Imsi) } } diff --git a/internal/promclient/promclient.go b/internal/promclient/promclient.go index c421e43..5b72c71 100644 --- a/internal/promclient/promclient.go +++ b/internal/promclient/promclient.go @@ -16,6 +16,7 @@ import ( type PromStats struct { coreSub *prometheus.CounterVec + violSub *prometheus.CounterVec smfSvcStat *prometheus.CounterVec amfSvcStat *prometheus.CounterVec smfSessions *prometheus.GaugeVec @@ -48,6 +49,11 @@ func initPromStats() *PromStats { Help: "core subscriber info", }, []string{"imsi", "ip_addr", "state", "smf_ip", "dnn", "slice", "upf"}), + violSub: prometheus.NewCounterVec(prometheus.CounterOpts{ + Name: "viol_subscriber", + Help: "violated subscriber info", + }, []string{"imsi", "ip_addr", "state"}), + smfSessions: prometheus.NewGaugeVec(prometheus.GaugeOpts{ Name: "smf_pdu_sessions", Help: "Number of SMF PDU sessions currently in the core", @@ -76,6 +82,11 @@ func (ps *PromStats) register() error { return err } + if err := prometheus.Register(ps.violSub); err != nil { + logger.PromLog.Errorf("register viol subscriber detail stats failed: %v", err.Error()) + return err + } + if err := prometheus.Register(ps.smfSessions); err != nil { logger.PromLog.Errorf("register core subscriber count stats failed: %v", err.Error()) return err @@ -115,6 +126,22 @@ func DeleteCoreSubData(imsi, ip_addr, state, smf_ip, dnn, slice, upf string) { promStats.coreSub.DeleteLabelValues(imsi, ip_addr, state, smf_ip, dnn, slice, upf) } +func PushViolSubData(imsi, ip_addr, state string) { + logger.PromLog.Debugf( + "adding viol subscriber data [%v, %v, %v]", + imsi, ip_addr, + ) + promStats.violSub.WithLabelValues(imsi, ip_addr, state).Inc() +} + +func DeleteViolSubData(imsi, ip_addr, state string) { + logger.PromLog.Debugf( + "deleting viol subscriber data [%v, %v, %v]", + imsi, ip_addr, + ) + promStats.violSub.DeleteLabelValues(imsi, ip_addr, state) +} + // SetSessStats maintains Session level stats func SetSmfSessStats(smfIp, slice, dnn, upf string, count uint64) { logger.PromLog.Debugf( From 56c71496706a563097833bc976e05a7469978d02 Mon Sep 17 00:00:00 2001 From: "Marikkannu, Suresh" Date: Fri, 9 May 2025 02:45:31 -0700 Subject: [PATCH 2/5] Fix lint issues Signed-off-by: Marikkannu, Suresh --- controller/controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/controller.go b/controller/controller.go index 02e5b86..5b03b35 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -17,9 +17,9 @@ import ( "strings" "time" - "github.com/omec-project/metricfunc/internal/promclient" "github.com/omec-project/metricfunc/config" "github.com/omec-project/metricfunc/internal/metricdata" + "github.com/omec-project/metricfunc/internal/promclient" "github.com/omec-project/metricfunc/logger" "golang.org/x/net/http2" ) From 5248d01cd42ab63238e332c6cf2cfecb7d4c6c26 Mon Sep 17 00:00:00 2001 From: "Marikkannu, Suresh" Date: Tue, 13 May 2025 01:56:22 -0700 Subject: [PATCH 3/5] Remove DeleteViol function which is not needed Signed-off-by: Marikkannu, Suresh --- controller/controller.go | 3 +-- internal/promclient/promclient.go | 8 -------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/controller/controller.go b/controller/controller.go index 5b03b35..e9252f9 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -367,15 +367,14 @@ func RogueIPHandler(rogueIPChannel chan RogueIPs) { continue } logger.ControllerLog.Infof("subscriber Imsi [%v] of the IP: [%v]", subscriberInfo.Imsi, ipaddr) - promclient.PushViolSubData(subscriberInfo.Imsi, ipaddr, "Active") // get enterprises or targets from ROC targets := rocClient.GetTargets() if len(targets) == 0 { + promclient.PushViolSubData(subscriberInfo.Imsi, ipaddr, "Active") logger.ControllerLog.Errorln("get targets returns nil") } else { // get siteinfo from ROC - promclient.DeleteViolSubData(subscriberInfo.Imsi, ipaddr, "Active") promclient.PushViolSubData(subscriberInfo.Imsi, ipaddr, "Resolved") rocClient.DisableSimcard(targets, subscriberInfo.Imsi) } diff --git a/internal/promclient/promclient.go b/internal/promclient/promclient.go index 5b72c71..81192a7 100644 --- a/internal/promclient/promclient.go +++ b/internal/promclient/promclient.go @@ -134,14 +134,6 @@ func PushViolSubData(imsi, ip_addr, state string) { promStats.violSub.WithLabelValues(imsi, ip_addr, state).Inc() } -func DeleteViolSubData(imsi, ip_addr, state string) { - logger.PromLog.Debugf( - "deleting viol subscriber data [%v, %v, %v]", - imsi, ip_addr, - ) - promStats.violSub.DeleteLabelValues(imsi, ip_addr, state) -} - // SetSessStats maintains Session level stats func SetSmfSessStats(smfIp, slice, dnn, upf string, count uint64) { logger.PromLog.Debugf( From ab8f94f9a6288bc600f186b9df797ee367020147 Mon Sep 17 00:00:00 2001 From: "Marikkannu, Suresh" Date: Tue, 13 May 2025 21:15:45 -0700 Subject: [PATCH 4/5] Update logging statement to include state Signed-off-by: Marikkannu, Suresh --- internal/promclient/promclient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/promclient/promclient.go b/internal/promclient/promclient.go index 81192a7..4e4ea56 100644 --- a/internal/promclient/promclient.go +++ b/internal/promclient/promclient.go @@ -129,7 +129,7 @@ func DeleteCoreSubData(imsi, ip_addr, state, smf_ip, dnn, slice, upf string) { func PushViolSubData(imsi, ip_addr, state string) { logger.PromLog.Debugf( "adding viol subscriber data [%v, %v, %v]", - imsi, ip_addr, + imsi, ip_addr, state, ) promStats.violSub.WithLabelValues(imsi, ip_addr, state).Inc() } From d33ff1ddb20f2e9ea0b3f73f3923b7a4d87f94cd Mon Sep 17 00:00:00 2001 From: "Marikkannu, Suresh" Date: Tue, 13 May 2025 21:19:41 -0700 Subject: [PATCH 5/5] Update VERSION file to create image for metric-func Signed-off-by: Marikkannu, Suresh --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 40488c2..266146b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.6.3-dev +1.6.3