feat: add prometheus metrics support #173
Conversation
|
Congratulations @Niahh for your first PRs to free5gc! :-) |
d03ad7b to
82c4a78
Compare
|
It's so nice to see those contributions! |
|
FYI : Need to run a golangci on each commit + rebase to resolve conflict (working on that) Edit: Done 😁 |
dff1e0d to
13dfdee
Compare
| if cfg.AreMetricsEnabled() { | ||
| if amf.metricsServer, err = metrics.NewServer( | ||
| getInitMetrics(cfg, commonMetrics, getCustomMetrics(cfg)), tlsKeyLogPath, logger.InitLog); err != nil { | ||
| return nil, err |
There was a problem hiding this comment.
Do we treat it as an error?
Or print a warning log and continue the initialization?
There was a problem hiding this comment.
I was assuming that if the metrics were enabled in the config, an error would be better than a warning. However it is a side functionality to the NF so we could just log a warning. Let me look in the code to see if no weird case would happen with the current metrics implementation if we just logs a warning 😄
|
@Niahh |
|
I refactored with a link to the latest main branch, I´m awaiting a release of openapi to update it again. Regarding the comment you made @ianchen0119 about logging a warning if the metrics server do not initialize properly, I decided to keep the error due to the fact that it is a opt-in configuration. If the server had some trouble during the initialization, with only a warning the user could overlook it (there is a lot of logs at start up), and in an automation script it could lead to a misinterpretation that everything is as the user expect it to be in the config. If not mandatory for the user and they don't want to fix the error, they can just disable the metrics in the configuration. What do you think ? |
|
@ianchen0119 @Alonza0314 I think the rest of the parts look good to me. |
|
I just released the new openapi version: https://github.com/free5gc/openapi/releases
It makes sense to me, I think the current implementation is good. |
|
Hello @ianchen0119, I have updated the PRs to point out directly to the new Openapi 1.2.1 release 🎉. It should now pass every pipelines, I will keep an eye if that is not the case 😁. |
This PR introduces Prometheus-compatible metrics to the AMF to support observability and performance monitoring in Free5GC deployments.
Key Features
/metricsHTTP endpoint that is configurable and compatible with Prometheus scraping.metricspackage in theUtilproject to minimize code coupling and simplify reuse across NFs.Motivation
Introducing native metrics is a foundational step toward:
Configuration
The metrics server is disabled by default. To enable, add the proper section :
Performance impact
Tests were made for NAS and NGAP message handling with metrics enabled and metrics disabled over 1000 iterations
NAS
16% Bytes Handled by operation Increased
9% Number of Allocation by operation
NGAP
6,6% Bytes Handled by operation Increased
3,4% Number of Allocation by operation
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
Quick view of the metrics produced
This work is sponsored by Free Mobile!