[GH-ISSUE #2836] Optionally disable Prometheus metrics #5985

Open
opened 2026-08-05 01:06:10 -04:00 by saavagebueno · 4 comments
Owner

Originally created by @PatrickDaG on GitHub (Nov 2, 2024).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/2836

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). Original GitHub issue: https://github.com/netbirdio/netbird/issues/2836 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 2026-08-05 01:06:10 -04: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?

<!-- gh-comment-id:2458102726 --> @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.

<!-- gh-comment-id:2458227495 --> @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.

<!-- gh-comment-id:2752548495 --> @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.
Author
Owner

@mtdcr commented on GitHub (Feb 15, 2026):

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.

This might be true, but disabling an unused service reduces its attack surface to exactly zero, which is hard to compete with.

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

This statement is logically wrong. A disabled service will never be called. The conditional would appear before initialization and would save a negligible amount of initialization time.

A disabled service will never leak information about another service, which is what prometheus metrics usually do.

Being able to opt-out doesn't seem have any obvious negative side effects.

<!-- gh-comment-id:3904236365 --> @mtdcr commented on GitHub (Feb 15, 2026): > 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. This might be true, but disabling an unused service reduces its attack surface to exactly zero, which is hard to compete with. > In fact, making it toggleable can actually add overhead since you have to have an if statement wrapped around every call. This statement is logically wrong. A disabled service will never be called. The conditional would appear before initialization and would save a negligible amount of initialization time. A disabled service will never leak information about another service, which is what prometheus metrics usually do. Being able to opt-out doesn't seem have any obvious negative side effects.
Sign in to join this conversation.
No Label feature-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#5985