Don't initialize telemetry listener at all if ZEEKCTL_CHECK_CONFIG is set

This commit is contained in:
Tim Wojtulewicz 2025-04-04 16:23:53 -07:00
parent 5c47533653
commit 4f0d18f45f

View file

@ -55,7 +55,7 @@ void Manager::InitPostScript() {
if ( metrics_port->Port() != 0 ) if ( metrics_port->Port() != 0 )
prometheus_url = util::fmt("%s:%u", metrics_address.data(), metrics_port->Port()); prometheus_url = util::fmt("%s:%u", metrics_address.data(), metrics_port->Port());
if ( ! prometheus_url.empty() ) { if ( ! prometheus_url.empty() && ! getenv("ZEEKCTL_CHECK_CONFIG") ) {
CivetCallbacks* callbacks = nullptr; CivetCallbacks* callbacks = nullptr;
auto local_node_name = id::find_val("Cluster::node")->AsStringVal(); auto local_node_name = id::find_val("Cluster::node")->AsStringVal();
if ( local_node_name->Len() > 0 ) { if ( local_node_name->Len() > 0 ) {
@ -87,11 +87,9 @@ void Manager::InitPostScript() {
} }
} }
if ( ! getenv("ZEEKCTL_CHECK_CONFIG") ) {
try { try {
prometheus_exposer = prometheus_exposer =
std::make_unique<prometheus::Exposer>(prometheus_url, BifConst::Telemetry::civetweb_threads, std::make_unique<prometheus::Exposer>(prometheus_url, BifConst::Telemetry::civetweb_threads, callbacks);
callbacks);
// CivetWeb stores a copy of the callbacks, so we're safe to delete the pointer here // CivetWeb stores a copy of the callbacks, so we're safe to delete the pointer here
delete callbacks; delete callbacks;
@ -109,7 +107,6 @@ void Manager::InitPostScript() {
prometheus_exposer->RegisterCollectable(prometheus_registry); prometheus_exposer->RegisterCollectable(prometheus_registry);
} }
}
#ifdef HAVE_PROCESS_STAT_METRICS #ifdef HAVE_PROCESS_STAT_METRICS
static auto get_stats = []() -> const detail::process_stats* { static auto get_stats = []() -> const detail::process_stats* {