Merge pull request #8 from zerotier/2152-disable-metrics

Allow metrics to be disabled
This commit is contained in:
Joseph Henry
2025-11-10 09:39:43 -08:00
committed by GitHub
3 changed files with 14 additions and 2 deletions

View File

@@ -1,6 +1,10 @@
ZeroTier Release Notes
======
## WORK-IN-PROGRESS
* Metrics collection is now disabled by default. It can be enabled via the `enableMetrics` setting in `local.conf`.
## 2025-08-21 -- Version 1.16.0
* License Changes

View File

@@ -988,7 +988,6 @@ class OneServiceImpl : public OneService {
_ports[1] = 0;
_ports[2] = 0;
prometheus::simpleapi::saver.set_registry(prometheus::simpleapi::registry_ptr);
prometheus::simpleapi::saver.set_delay(std::chrono::seconds(5));
prometheus::simpleapi::saver.set_out_file(_homePath + ZT_PATH_SEPARATOR + "metrics.prom");
@@ -2931,6 +2930,15 @@ class OneServiceImpl : public OneService {
_allowManagementFrom.push_back(nw);
}
}
bool enableMetrics = OSUtils::jsonBool(settings["enableMetrics"], false);
if (enableMetrics) {
prometheus::simpleapi::saver.set_registry(prometheus::simpleapi::registry_ptr);
}
else {
std::shared_ptr<prometheus::Registry> registry;
prometheus::simpleapi::saver.set_registry(registry);
}
}
#if ZT_VAULT_SUPPORT

View File

@@ -41,7 +41,7 @@ Settings available in `local.conf` (this is not valid JSON, and JSON does not al
"allowManagementFrom": [ "NETWORK/bits", ...] |null, /* If non-NULL, allow JSON/HTTP management from this IP network. Default is 127.0.0.1 only. */
"bind": [ "ip",... ], /* If present and non-null, bind to these IPs instead of to each interface (wildcard IP allowed) */
"allowTcpFallbackRelay": true|false, /* Allow or disallow establishment of TCP relay connections (true by default) */
"multipathMode": 0|1|2 /* multipath mode: none (0), random (1), proportional (2) */
"enableMetrics": true|false /* If true, enable the collection of metrics in metrics.prom. */
}
}
```