Skip to content

Conversation

@Niahh
Copy link
Contributor

@Niahh Niahh commented Jul 10, 2025

This PR introduces Prometheus-compatible metrics to the NSSF to support observability and performance monitoring in Free5GC deployments.

Key Features

  • SBI Metrics: Track inbound/outbound HTTP requests on the Service-Based Interface (SBI) with counters and latency histograms.
  • Built-in Metric Server: Exposes a /metrics HTTP endpoint that is configurable and compatible with Prometheus scraping.
  • Modular Design: Metrics logic is isolated in a dedicated metrics package in the Util project to minimize code coupling and simplify reuse across NFs.
  • No External Dependencies: Uses the official Prometheus Go client library only — no sidecars or exporters required.

Motivation

Introducing native metrics is a foundational step toward:

  • Understanding real-time behavior of the NSSF
  • Coupled with testing tools such as PacketRusher, it can help with debugging some scenarios.
  • Integrating Free5GC into production-grade observability stacks (e.g., Prometheus + Grafana)

Configuration

The metrics server is disabled by default. To enable, add the proper section :

# Metrics configuration
# If using the same bindingIPv4 as the sbi server, make sure that the ports are different
metrics:
	enable: true # (Optional, default false)
	scheme: http # (Required) the protocol for metrics (http or https, default https)
	bindingIPv4: 127.0.0.18 # (Required) IP used to bind the metrics endpoint (default 0.0.0.0)
	port: 9091 # (Optional, default 9091) port used to bind the service
	tls: # (Optional) the local path of TLS key (Could be the same as the sbi ones)
		pem: /home/sam/private-network/code/free5gc/cert/NSSF.pem # NSSF TLS Certificate
		key: /home/sam/private-network/code/free5gc/cert/NSSF.key # NSSF TLS Private key
	namespace: free5gc # (Optional, default free5gc)

Backward Compatibility

100% backward compatible – metrics support is optional and deactivated until activated by the user.

Integration

The same metrics architecture is being adapted across other Free5GC NFs (AUSF, NRF, SMF , etc.) to ensure consistency and maintainability.

Pictures

Example of metrics produced

image

This work is sponsored by Free Mobile!

@Niahh Niahh force-pushed the add-metrics branch 2 times, most recently from 275035d to 25cb16e Compare July 15, 2025 14:31
@leowu0407
Copy link
Contributor

@ianchen0119 @Alonza0314 LGTM

Copy link
Member

@Alonza0314 Alonza0314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Alonza0314 Alonza0314 requested a review from ianchen0119 August 1, 2025 09:44
@ianchen0119 ianchen0119 merged commit 3bb6990 into free5gc:main Aug 14, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants