From 777b0be03e4e62783910e205b21877286f66598e Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Thu, 6 Jun 2024 12:34:46 -0700 Subject: [PATCH] Check for 'zeekctl check' before trying to start up prometheus --- src/telemetry/Manager.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/telemetry/Manager.cc b/src/telemetry/Manager.cc index 3ad3968e7d..d8343a1a43 100644 --- a/src/telemetry/Manager.cc +++ b/src/telemetry/Manager.cc @@ -70,16 +70,18 @@ void Manager::InitPostScript() { } } - try { - prometheus_exposer = std::make_unique(prometheus_url, 2, callbacks); + if ( ! getenv("ZEEKCTL_CHECK_CONFIG") ) { + try { + prometheus_exposer = std::make_unique(prometheus_url, 2, callbacks); - // CivetWeb stores a copy of the callbacks, so we're safe to delete the pointer here - delete callbacks; - } catch ( const CivetException& exc ) { - reporter->FatalError("Failed to setup Prometheus endpoint: %s\n", exc.what()); + // CivetWeb stores a copy of the callbacks, so we're safe to delete the pointer here + delete callbacks; + } catch ( const CivetException& exc ) { + reporter->FatalError("Failed to setup Prometheus endpoint: %s\n", exc.what()); + } + + prometheus_exposer->RegisterCollectable(prometheus_registry); } - - prometheus_exposer->RegisterCollectable(prometheus_registry); } #ifdef HAVE_PROCESS_STAT_METRICS