Skip to content

Conversation

@Niahh
Copy link
Contributor

@Niahh Niahh commented Jul 10, 2025

This PR introduces Prometheus-compatible metrics to the CHF 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 CHF
  • 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/CHF.pem # CHF TLS Certificate
		key: /home/sam/private-network/code/free5gc/cert/CHF.key # CHF 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.

This work is sponsored by Free Mobile!

@Niahh
Copy link
Contributor Author

Niahh commented Jul 11, 2025

Working on aliging the PR with all the errors/warning from golangci-lint and taking the latest change of upgrad_cli_to_v2

@ianchen0119
Copy link
Collaborator

@Niahh

The PR of the util has been merged. So you can use the latest util in all of related PRs now.

Thank you!

@Niahh
Copy link
Contributor Author

Niahh commented Jul 23, 2025

@Niahh

The PR of the util has been merged. So you can use the latest util in all of related PRs now.

Thank you!

Great thank you ! I will update every PR to include the main branch of free5gc's util as the latest tagged version doesn´t yet include the metrics 😄

Edit: I saw that you released the version 1.2.0 of util a few moments after my comment, I made the appropriate changes in the go mod 🚀

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:30
@ianchen0119 ianchen0119 merged commit 4056b6f 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.

3 participants