Integrate new Broker metric exporter parameters

This commit is contained in:
Dominik Charousset 2021-05-24 17:20:48 +02:00
parent 2c27f1bf34
commit f9cd05f00b
6 changed files with 160 additions and 2 deletions

View file

@ -31,7 +31,7 @@ export {
## authenticated.
const disable_ssl = F &redef;
## Path to a file containing concatenated trusted certificates
## Path to a file containing concatenated trusted certificates
## in PEM format. If set, Zeek will require valid certificates for
## all peers.
const ssl_cafile = "" &redef;
@ -122,6 +122,25 @@ export {
## done reading the pcap.
option peer_counts_as_iosource = T;
## Frequency for publishing scraped metrics to the target topic.
option metrics_exporter_interval = 1 sec;
## Target topic for the metrics. Setting a non-empty string starts the
#periodic publishing of local metrics.
option metrics_exporter_target = "";
## ID for the metrics exporter. When setting a target topic for the
# exporter, Broker sets this option to the suffix of the new topic *unless*
# the ID is a non-empty string. Since setting a topic starts the periodic
# publishing of events, we recommend setting the ID always first (or avoid
# setting it at all if the topic suffix serves as a good ID).
option metrics_exporter_id = "";
## Selects prefixes from the local metrics. Only metrics with prefixes
# listed in this variable are included when publishing local metrics.
# Setting an empty vector selects *all* metrics.
option metrics_exporter_prefixes: vector of string = vector();
## The default topic prefix where logs will be published. The log's stream
## id is appended when writing to a particular stream.
const default_log_topic_prefix = "zeek/logs/" &redef;
@ -385,9 +404,41 @@ event Broker::log_flush() &priority=10
schedule Broker::log_batch_interval { Broker::log_flush() };
}
function update_metrics_exporter_interval(id: string, val: interval): interval
{
Broker::__set_metrics_exporter_interval(val);
return val;
}
function update_metrics_exporter_target(id: string, val: string): string
{
Broker::__set_metrics_exporter_target(val);
return val;
}
function update_metrics_exporter_id(id: string, val: string): string
{
Broker::__set_metrics_exporter_id(val);
return val;
}
function update_metrics_exporter_prefixes(id: string, filter: vector of string): vector of string
{
Broker::__set_metrics_exporter_prefixes(filter);
return filter;
}
event zeek_init()
{
schedule Broker::log_batch_interval { Broker::log_flush() };
Option::set_change_handler("Broker::metrics_exporter_interval",
update_metrics_exporter_interval);
Option::set_change_handler("Broker::metrics_exporter_target",
update_metrics_exporter_target);
Option::set_change_handler("Broker::metrics_exporter_id",
update_metrics_exporter_id);
Option::set_change_handler("Broker::metrics_exporter_prefixes",
update_metrics_exporter_prefixes);
}
event retry_listen(a: string, p: port, retry: interval)