diff --git a/CHANGES b/CHANGES index 3db5c1a18b..65c0231d85 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +7.0.0-dev.372 | 2024-06-07 09:28:52 -0700 + + * Add Telemetry::metrics_address option (Tim Wojtulewicz, Corelight) + 7.0.0-dev.368 | 2024-06-06 18:08:29 -0700 * Change prometheus test to check for require jq (Tim Wojtulewicz, Corelight) diff --git a/VERSION b/VERSION index cf9ddbd318..b6f01341b8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.0.0-dev.370 +7.0.0-dev.372 diff --git a/scripts/base/frameworks/telemetry/options.zeek b/scripts/base/frameworks/telemetry/options.zeek index f26d8a0ef0..9e5adf1fbb 100644 --- a/scripts/base/frameworks/telemetry/options.zeek +++ b/scripts/base/frameworks/telemetry/options.zeek @@ -6,6 +6,10 @@ module Telemetry; # to see the options without needing the rest. export { + ## Address used to make metric data available to Prometheus scrapers via + ## HTTP. + const metrics_address = getenv("ZEEK_DEFAULT_LISTEN_ADDRESS") &redef; + ## Port used to make metric data available to Prometheus scrapers via ## HTTP. const metrics_port = 0/unknown &redef; diff --git a/src/telemetry/Manager.cc b/src/telemetry/Manager.cc index d8343a1a43..1df895dea1 100644 --- a/src/telemetry/Manager.cc +++ b/src/telemetry/Manager.cc @@ -35,8 +35,9 @@ void Manager::InitPostScript() { // Metrics port setting is used to calculate a URL for prometheus scraping std::string prometheus_url; auto metrics_port = id::find_val("Telemetry::metrics_port")->AsPortVal(); + auto metrics_address = id::find_val("Telemetry::metrics_address")->AsStringVal()->ToStdString(); if ( metrics_port->Port() != 0 ) - prometheus_url = util::fmt("localhost:%u", metrics_port->Port()); + prometheus_url = util::fmt("%s:%u", metrics_address.data(), metrics_port->Port()); if ( ! prometheus_url.empty() ) { CivetCallbacks* callbacks = nullptr; @@ -77,7 +78,8 @@ void Manager::InitPostScript() { // 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()); + reporter->FatalError("Failed to setup Prometheus endpoint: %s. Attempted to bind to %s.", exc.what(), + prometheus_url.c_str()); } prometheus_exposer->RegisterCollectable(prometheus_registry);