Optionally disable Prometheus metrics #1394

Open
opened 2025-11-20 05:29:35 -05:00 by saavagebueno · 3 comments
Owner

Originally created by @PatrickDaG on GitHub (Nov 2, 2024).

I am currently not able to take advantage of the exposed metrics by the signal, relay and management services and would like to keep my system as lean as possible for performance and security reasons.
Thus I was wondering why there currently seems to be no way to completely disable the exposed metrics.

I've taken a look at the code and it seems to be doable but non trivial to add such a feature, I would be open to do it and post a pull request, but before I do the work was wondering if it may be intentional that disabling is impossible?
The only alternative currently seems to be blocking the port, which isn't a perfect solution since usually services on the same host can still access the address.

Originally created by @PatrickDaG on GitHub (Nov 2, 2024). I am currently not able to take advantage of the exposed metrics by the signal, relay and management services and would like to keep my system as lean as possible for performance and security reasons. Thus I was wondering why there currently seems to be no way to completely disable the exposed metrics. I've taken a look at the code and it seems to be doable but non trivial to add such a feature, I would be open to do it and post a pull request, but before I do the work was wondering if it may be intentional that disabling is impossible? The only alternative currently seems to be blocking the port, which isn't a perfect solution since usually services on the same host can still access the address.
saavagebueno added the feature-request label 2025-11-20 05:29:35 -05:00
Author
Owner

@mlsmaycon commented on GitHub (Nov 5, 2024):

As the systems run on containers, you don't necessarily need to expose the prometheus ports, so it should only be accessible by the host. Is this an issue other than a little extra computing usage?

@mlsmaycon commented on GitHub (Nov 5, 2024): As the systems run on containers, you don't necessarily need to expose the prometheus ports, so it should only be accessible by the host. Is this an issue other than a little extra computing usage?
Author
Owner

@PatrickDaG commented on GitHub (Nov 5, 2024):

I'm running the system on bare metal and together with a bunch of other stuff, so less computing is always welcome. I know this isn't an officially supported setup, but I still feel like having the option to disable the metrics would be good.

As I said I will try and implement this myself, just wondering whether this is something you just didn't deem necessary and thus didn't want to put work into or if there are strong reasons for not providing this option.

@PatrickDaG commented on GitHub (Nov 5, 2024): I'm running the system on bare metal and together with a bunch of other stuff, so less computing is always welcome. I know this isn't an officially supported setup, but I still feel like having the option to disable the metrics would be good. As I said I will try and implement this myself, just wondering whether this is something you just didn't deem necessary and thus didn't want to put work into or if there are strong reasons for not providing this option.
Author
Owner

@SuperQ commented on GitHub (Mar 25, 2025):

I haven't looked at the specific implementation here, but disabling Prometheus metrics is going to provide near zero performance or security improvements. The Prometheus metrics library is extremely lightweight. We're talking about nanoseconds of CPU time.

In fact, making it toggleable can actually add overhead since you have to have an if statement wrapped around every call.

@SuperQ commented on GitHub (Mar 25, 2025): I haven't looked at the specific implementation here, but disabling Prometheus metrics is going to provide near zero performance or security improvements. The Prometheus metrics library is _extremely_ lightweight. We're talking about nanoseconds of CPU time. In fact, making it toggleable can actually add overhead since you have to have an if statement wrapped around every call.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#1394