From e3e806ca239d26c1cf85f8124233ceaa04023cec Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Thu, 16 May 2024 11:47:57 -0700 Subject: [PATCH] Remove all of the ZEEK_METRICS_ environment variables --- NEWS | 15 +++++++-------- scripts/base/frameworks/telemetry/main.zeek | 3 +-- scripts/base/frameworks/telemetry/options.zeek | 7 ++----- src/telemetry/Manager.cc | 10 +++------- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/NEWS b/NEWS index 91d1f9e895..818b088337 100644 --- a/NEWS +++ b/NEWS @@ -31,14 +31,13 @@ Breaking Changes The ``unit`` field has been removed from the telemetry log. - All of the ``BROKER_METRICS_*`` environment variables have been replaced with - ``ZEEK_METRICS_*`` versions. This is most prevalent in cluster configurations, - where ``ZEEK_METRICS_PORT`` should no longer be set for each node that wants - to output telemetry data. Instead, a new ``metrics_port`` option was added to - the ``node.cfg`` options and can be used to set the port number. The cluster - layout record defined in ``cluster-layout.zeek`` has the same option, and it - can be automatically populated by ``zeekctl`` during the ``install`` or - ``deploy`` commands. + All of the ``BROKER_METRICS_*`` environment variables have been removed. Use + the equivalent script-level variables for setting configuration settings. For + cluster settings, a new ``metrics_port`` option was added to the ``node.cfg`` + options and can be used to set the port number. The cluster layout record + defined in ``cluster-layout.zeek`` has the same option, and it can be + automatically populated by ``zeekctl`` during the ``install`` or ``deploy`` + commands. New Functionality ----------------- diff --git a/scripts/base/frameworks/telemetry/main.zeek b/scripts/base/frameworks/telemetry/main.zeek index 96f9aade6c..beb4ca3c1f 100644 --- a/scripts/base/frameworks/telemetry/main.zeek +++ b/scripts/base/frameworks/telemetry/main.zeek @@ -2,8 +2,7 @@ ##! the lower-level telemetry.bif functions. ##! ##! Metrics will be exposed through a Prometheus HTTP endpoint when -##! enabled by setting :zeek:see:`Telemetry::metrics_port` or using the -##! `ZEEK_METRICS_PORT` environment variable. +##! enabled by setting :zeek:see:`Telemetry::metrics_port`. @load base/misc/version @load base/frameworks/telemetry/options diff --git a/scripts/base/frameworks/telemetry/options.zeek b/scripts/base/frameworks/telemetry/options.zeek index 3494c4348e..f26d8a0ef0 100644 --- a/scripts/base/frameworks/telemetry/options.zeek +++ b/scripts/base/frameworks/telemetry/options.zeek @@ -7,14 +7,11 @@ module Telemetry; export { ## Port used to make metric data available to Prometheus scrapers via - ## HTTP. Zeek overrides any value provided in zeek_init or earlier at - ## startup if the environment variable ZEEK_METRICS_PORT is defined. + ## HTTP. const metrics_port = 0/unknown &redef; ## ID for the metrics exporter. This is used as the 'endpoint' label ## value when exporting data to Prometheus. In a cluster setup, this - ## defaults to the name of the node in the cluster configuration. Zeek - ## overrides any value provided in zeek_init or earlier at startup if - ## the environment variable ZEEK_METRICS_ENDPOINT_NAME is defined. + ## defaults to the name of the node in the cluster configuration. const metrics_endpoint_name = "" &redef; } diff --git a/src/telemetry/Manager.cc b/src/telemetry/Manager.cc index 618bd29405..c06dc4757a 100644 --- a/src/telemetry/Manager.cc +++ b/src/telemetry/Manager.cc @@ -28,13 +28,9 @@ Manager::Manager() { prometheus_registry = std::make_sharedAsPortVal(); - if ( metrics_port->Port() != 0 ) - prometheus_url = util::fmt("localhost:%u", metrics_port->Port()); - } + auto metrics_port = id::find_val("Telemetry::metrics_port")->AsPortVal(); + if ( metrics_port->Port() != 0 ) + prometheus_url = util::fmt("localhost:%u", metrics_port->Port()); if ( ! prometheus_url.empty() ) { CivetCallbacks* callbacks = nullptr;