Merge branch 'topic/christian/telemetry-make-bifs-primary'

* topic/christian/telemetry-make-bifs-primary:
  Telemetry framework: move BIFs to the primary-bif stage
  Minor comment tweaks for init-frameworks-and-bifs.zeek
This commit is contained in:
Christian Kreibich 2024-10-24 07:08:45 -07:00
commit 66173633f4
23 changed files with 108 additions and 67 deletions

View file

@ -5,28 +5,10 @@
##! enabled by setting :zeek:see:`Telemetry::metrics_port`.
@load base/misc/version
@load base/frameworks/cluster
@load base/frameworks/telemetry/options
@load base/bif/telemetry_functions.bif
module Telemetry;
# In a cluster configuration, open the port number for metrics
# from the cluster node configuration for exporting data to
# Prometheus.
#
# The manager node will also provide a ``/services.json`` endpoint
# for the HTTP Service Discovery system in Prometheus to use for
# configuration. This endpoint will include information for all of
# the other nodes in the cluster.
@if ( Cluster::is_enabled() )
redef Telemetry::metrics_endpoint_name = Cluster::node;
@if ( Cluster::local_node_metrics_port() != 0/unknown )
redef Telemetry::metrics_port = Cluster::local_node_metrics_port();
@endif
@endif
export {
## Alias for a vector of label values.
type labels_vector: vector of string;

View file

@ -1,9 +1,10 @@
module Telemetry;
##! Configurable settings for the Telemetry framework.
##!
##! These reside separately from the main framework so that they can be loaded
##! in bare mode without all of the framework. This allows things like the
##! plugins.hooks test to see the options without needing the rest.
# This file contains the options for the Telemetry framework. These are kept
# separately so that they can be loaded in bare mode without loading all of
# the rest of the framework. This allows things like the plugins.hooks test
# to see the options without needing the rest.
module Telemetry;
export {
## Address used to make metric data available to Prometheus scrapers via
@ -19,3 +20,23 @@ export {
## defaults to the name of the node in the cluster configuration.
const metrics_endpoint_name = "" &redef;
}
# When running a cluster, use the metrics port from the cluster node
# configuration for exporting data to Prometheus.
#
# The manager node will also provide a ``/services.json`` endpoint
# for the HTTP Service Discovery system in Prometheus to use for
# configuration. This endpoint will include information for all of
# the other nodes in the cluster.
# We do this here, and not in main.zeek, to avoid ordering issues when loading
# the telemetry and cluster frameworks. This applies even in bare mode, per
# init-frameworks-and-bifs.zeek: the cluster's metrics ports need to be available
# for the redefs to assign the correct values.
@if ( Cluster::is_enabled() )
redef Telemetry::metrics_endpoint_name = Cluster::node;
@if ( Cluster::local_node_metrics_port() != 0/unknown )
redef Telemetry::metrics_port = Cluster::local_node_metrics_port();
@endif
@endif