Remove all of the ZEEK_METRICS_ environment variables

This commit is contained in:
Tim Wojtulewicz 2024-05-16 11:47:57 -07:00
parent 635198793d
commit e3e806ca23
4 changed files with 13 additions and 22 deletions

15
NEWS
View file

@ -31,14 +31,13 @@ Breaking Changes
The ``unit`` field has been removed from the telemetry log. The ``unit`` field has been removed from the telemetry log.
All of the ``BROKER_METRICS_*`` environment variables have been replaced with All of the ``BROKER_METRICS_*`` environment variables have been removed. Use
``ZEEK_METRICS_*`` versions. This is most prevalent in cluster configurations, the equivalent script-level variables for setting configuration settings. For
where ``ZEEK_METRICS_PORT`` should no longer be set for each node that wants cluster settings, a new ``metrics_port`` option was added to the ``node.cfg``
to output telemetry data. Instead, a new ``metrics_port`` option was added to options and can be used to set the port number. The cluster layout record
the ``node.cfg`` options and can be used to set the port number. The cluster defined in ``cluster-layout.zeek`` has the same option, and it can be
layout record defined in ``cluster-layout.zeek`` has the same option, and it automatically populated by ``zeekctl`` during the ``install`` or ``deploy``
can be automatically populated by ``zeekctl`` during the ``install`` or commands.
``deploy`` commands.
New Functionality New Functionality
----------------- -----------------

View file

@ -2,8 +2,7 @@
##! the lower-level telemetry.bif functions. ##! the lower-level telemetry.bif functions.
##! ##!
##! Metrics will be exposed through a Prometheus HTTP endpoint when ##! Metrics will be exposed through a Prometheus HTTP endpoint when
##! enabled by setting :zeek:see:`Telemetry::metrics_port` or using the ##! enabled by setting :zeek:see:`Telemetry::metrics_port`.
##! `ZEEK_METRICS_PORT` environment variable.
@load base/misc/version @load base/misc/version
@load base/frameworks/telemetry/options @load base/frameworks/telemetry/options

View file

@ -7,14 +7,11 @@ module Telemetry;
export { export {
## Port used to make metric data available to Prometheus scrapers via ## Port used to make metric data available to Prometheus scrapers via
## HTTP. Zeek overrides any value provided in zeek_init or earlier at ## HTTP.
## startup if the environment variable ZEEK_METRICS_PORT is defined.
const metrics_port = 0/unknown &redef; const metrics_port = 0/unknown &redef;
## ID for the metrics exporter. This is used as the 'endpoint' label ## ID for the metrics exporter. This is used as the 'endpoint' label
## value when exporting data to Prometheus. In a cluster setup, this ## value when exporting data to Prometheus. In a cluster setup, this
## defaults to the name of the node in the cluster configuration. Zeek ## defaults to the name of the node in the cluster configuration.
## overrides any value provided in zeek_init or earlier at startup if
## the environment variable ZEEK_METRICS_ENDPOINT_NAME is defined.
const metrics_endpoint_name = "" &redef; const metrics_endpoint_name = "" &redef;
} }

View file

@ -28,13 +28,9 @@ Manager::Manager() { prometheus_registry = std::make_shared<prometheus::Registry
void Manager::InitPostScript() { void Manager::InitPostScript() {
// Metrics port setting is used to calculate a URL for prometheus scraping // Metrics port setting is used to calculate a URL for prometheus scraping
std::string prometheus_url; std::string prometheus_url;
if ( auto env = getenv("ZEEK_METRICS_PORT") )
prometheus_url = util::fmt("localhost:%s", env);
else {
auto metrics_port = id::find_val("Telemetry::metrics_port")->AsPortVal(); auto metrics_port = id::find_val("Telemetry::metrics_port")->AsPortVal();
if ( metrics_port->Port() != 0 ) if ( metrics_port->Port() != 0 )
prometheus_url = util::fmt("localhost:%u", metrics_port->Port()); prometheus_url = util::fmt("localhost:%u", metrics_port->Port());
}
if ( ! prometheus_url.empty() ) { if ( ! prometheus_url.empty() ) {
CivetCallbacks* callbacks = nullptr; CivetCallbacks* callbacks = nullptr;