Skip to content

Conversation

@Niahh
Copy link
Contributor

@Niahh Niahh commented Jul 10, 2025

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

@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

@ianchen0119 ianchen0119 merged commit b1e5127 into free5gc:main Aug 1, 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