mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Remove Broker metrics configuration values and methods
This commit is contained in:
parent
1cad305e58
commit
128bf3fe9f
5 changed files with 0 additions and 292 deletions
|
@ -135,45 +135,6 @@ export {
|
|||
## done reading the pcap.
|
||||
option peer_counts_as_iosource = T;
|
||||
|
||||
## Port for Broker's metric exporter. Setting this to a valid TCP port causes
|
||||
## Broker to make metrics available to Prometheus scrapers via HTTP. Zeek
|
||||
## overrides any value provided in zeek_init or earlier at startup if the
|
||||
## environment variable BROKER_METRICS_PORT is defined.
|
||||
const metrics_port = 0/unknown &redef &deprecated="Remove in 7.1. Use Telemetry::metrics_port.";
|
||||
|
||||
## Frequency for publishing scraped metrics to the target topic. Zeek
|
||||
## overrides any value provided in zeek_init or earlier at startup if the
|
||||
## environment variable BROKER_METRICS_EXPORT_INTERVAL is defined.
|
||||
option metrics_export_interval = 1 sec &deprecated="Remove in 7.1. Use Telemetry::metrics_export_interval";
|
||||
|
||||
## Target topic for the metrics. Setting a non-empty string starts the
|
||||
## periodic publishing of local metrics. Zeek overrides any value provided in
|
||||
## zeek_init or earlier at startup if the environment variable
|
||||
## BROKER_METRICS_EXPORT_TOPIC is defined.
|
||||
option metrics_export_topic = "" &deprecated="Remove in 7.1. Use Telemetry::metrics_export_topic";
|
||||
|
||||
## Topics for the Prometheus exporter for collecting metrics from other
|
||||
## peers in the network and including them in the output. Has no effect when
|
||||
## not exporting the metrics to Prometheus.
|
||||
##
|
||||
## Zeek overrides any value provided in zeek_init or earlier at startup if
|
||||
## the environment variable BROKER_METRICS_IMPORT_TOPICS is defined.
|
||||
option metrics_import_topics: vector of string = vector() &deprecated="Remove in 7.1. Use Telemetry::metrics_import_topics";
|
||||
|
||||
## 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-enough ID. Zeek
|
||||
## overrides any value provided in zeek_init or earlier at startup if the
|
||||
## environment variable BROKER_METRICS_ENDPOINT_NAME is defined.
|
||||
option metrics_export_endpoint_name = "" &deprecated="Remove in 7.1. Use Telemetry::metrics_export_endpoint_name";
|
||||
|
||||
## 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_export_prefixes: vector of string = vector() &deprecated="Remove in 7.1. Use Telemetry::metrics_export_prefixes";
|
||||
|
||||
## 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;
|
||||
|
@ -458,68 +419,9 @@ event Broker::log_flush() &priority=10
|
|||
schedule Broker::log_batch_interval { Broker::log_flush() };
|
||||
}
|
||||
|
||||
function update_metrics_export_interval(id: string, val: interval): interval &deprecated="Remove in v7.1. Use Telemetry::update_metrics_export_interval."
|
||||
{
|
||||
Broker::__set_metrics_export_interval(val);
|
||||
return val;
|
||||
}
|
||||
|
||||
function update_metrics_export_topic(id: string, val: string): string &deprecated="Remove in v7.1. Use Telemetry::update_metrics_export_topic."
|
||||
{
|
||||
Broker::__set_metrics_export_topic(val);
|
||||
return val;
|
||||
}
|
||||
|
||||
function update_metrics_import_topics(id: string, topics: vector of string): vector of string &deprecated="Remove in v7.1. Use Telemetry::update_metrics_import_topics."
|
||||
{
|
||||
Broker::__set_metrics_import_topics(topics);
|
||||
return topics;
|
||||
}
|
||||
|
||||
function update_metrics_export_endpoint_name(id: string, val: string): string &deprecated="Remove in v7.1. Use Telemetry::update_metrics_export_endpoint_name."
|
||||
{
|
||||
Broker::__set_metrics_export_endpoint_name(val);
|
||||
return val;
|
||||
}
|
||||
|
||||
function update_metrics_export_prefixes(id: string, filter: vector of string): vector of string &deprecated="Remove in v7.1. Use Telemetry::update_metrics_export_prefixes."
|
||||
{
|
||||
Broker::__set_metrics_export_prefixes(filter);
|
||||
return filter;
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
schedule Broker::log_batch_interval { Broker::log_flush() };
|
||||
|
||||
# Remove in v7.1.
|
||||
@pragma push ignore-deprecations
|
||||
# interval
|
||||
update_metrics_export_interval("Broker::metrics_export_interval",
|
||||
Broker::metrics_export_interval);
|
||||
Option::set_change_handler("Broker::metrics_export_interval",
|
||||
update_metrics_export_interval);
|
||||
# topic
|
||||
update_metrics_export_topic("Broker::metrics_export_topic",
|
||||
Broker::metrics_export_topic);
|
||||
Option::set_change_handler("Broker::metrics_export_topic",
|
||||
update_metrics_export_topic);
|
||||
# import topics
|
||||
update_metrics_import_topics("Broker::metrics_import_topics",
|
||||
Broker::metrics_import_topics);
|
||||
Option::set_change_handler("Broker::metrics_import_topics",
|
||||
update_metrics_import_topics);
|
||||
# endpoint name
|
||||
update_metrics_export_endpoint_name("Broker::metrics_export_endpoint_name",
|
||||
Broker::metrics_export_endpoint_name);
|
||||
Option::set_change_handler("Broker::metrics_export_endpoint_name",
|
||||
update_metrics_export_endpoint_name);
|
||||
# prefixes
|
||||
update_metrics_export_prefixes("Broker::metrics_export_prefixes",
|
||||
Broker::metrics_export_prefixes);
|
||||
Option::set_change_handler("Broker::metrics_export_prefixes",
|
||||
update_metrics_export_prefixes);
|
||||
@pragma pop
|
||||
}
|
||||
|
||||
event retry_listen(a: string, p: port, retry: interval)
|
||||
|
|
|
@ -331,82 +331,6 @@ void Manager::InitPostScript() {
|
|||
config.set("caf.work-stealing.moderate-steal-interval", get_option("Broker::moderate_interval")->AsCount());
|
||||
config.set("caf.work-stealing.relaxed-steal-interval", get_option("Broker::relaxed_interval")->AsCount());
|
||||
|
||||
// Before launching Broker, we check whether the configuration contains
|
||||
// values for the metric_exporter_* options. If Broker already has picked up
|
||||
// values from environment variables (or config files) then we write then
|
||||
// back. Otherwise, we forward user-defined values from script land (but
|
||||
// ignore defaults).
|
||||
WITH_OPT_MAPPING("broker.metrics.port", "Broker::metrics_port") {
|
||||
if ( auto port = opt.broker_read<uint16_t>() ) {
|
||||
opt.zeek_write(broker::port{*port, broker::port::protocol::tcp});
|
||||
}
|
||||
else {
|
||||
auto ptr = opt.zeek_read()->AsPortVal();
|
||||
if ( ptr->IsTCP() )
|
||||
opt.broker_write(ptr->Port());
|
||||
}
|
||||
}
|
||||
|
||||
WITH_OPT_MAPPING("broker.metrics.export.interval", "Broker::metrics_export_interval") {
|
||||
if ( auto ts = opt.broker_read<broker::timespan>() ) {
|
||||
opt.zeek_write(*ts);
|
||||
}
|
||||
else {
|
||||
using std::chrono::duration_cast;
|
||||
auto val = opt.zeek_read()->AsInterval();
|
||||
auto frac_ts = broker::fractional_seconds{val};
|
||||
if ( frac_ts.count() > 0.0 )
|
||||
opt.broker_write(duration_cast<broker::timespan>(frac_ts));
|
||||
}
|
||||
}
|
||||
|
||||
WITH_OPT_MAPPING("broker.metrics.export.topic", "Broker::metrics_export_topic") {
|
||||
if ( auto str = opt.broker_read<std::string>() ) {
|
||||
opt.zeek_write(*str);
|
||||
}
|
||||
else {
|
||||
auto ptr = opt.zeek_read()->AsStringVal();
|
||||
if ( ptr->Len() > 0 )
|
||||
opt.broker_write(ptr->ToStdString());
|
||||
}
|
||||
}
|
||||
|
||||
WITH_OPT_MAPPING("broker.metrics.endpoint-name", "Broker::metrics_export_endpoint_name") {
|
||||
if ( auto str = opt.broker_read<std::string>() ) {
|
||||
opt.zeek_write(*str);
|
||||
}
|
||||
else {
|
||||
auto ptr = opt.zeek_read()->AsStringVal();
|
||||
if ( ptr->Len() > 0 )
|
||||
opt.broker_write(ptr->ToStdString());
|
||||
}
|
||||
}
|
||||
|
||||
WITH_OPT_MAPPING("broker.metrics.export.prefixes", "Broker::metrics_export_prefixes") {
|
||||
if ( auto str = opt.broker_read<std::vector<std::string>>() ) {
|
||||
opt.zeek_write(*str);
|
||||
}
|
||||
else {
|
||||
auto ptr = opt.zeek_read()->AsVectorVal();
|
||||
std::vector<std::string> str_ls;
|
||||
for ( unsigned index = 0; index < ptr->Size(); ++index )
|
||||
str_ls.emplace_back(ptr->StringValAt(index)->ToStdString());
|
||||
opt.broker_write(std::move(str_ls));
|
||||
}
|
||||
}
|
||||
WITH_OPT_MAPPING("broker.metrics.import.topics", "Broker::metrics_import_topics") {
|
||||
if ( auto topics = opt.broker_read<std::vector<std::string>>() ) {
|
||||
opt.zeek_write(*topics);
|
||||
}
|
||||
else {
|
||||
auto ptr = opt.zeek_read()->AsVectorVal();
|
||||
std::vector<std::string> str_ls;
|
||||
for ( unsigned index = 0; index < ptr->Size(); ++index )
|
||||
str_ls.emplace_back(ptr->StringValAt(index)->ToStdString());
|
||||
opt.broker_write(std::move(str_ls));
|
||||
}
|
||||
}
|
||||
|
||||
auto cqs = get_option("Broker::congestion_queue_size")->AsCount();
|
||||
bstate = std::make_shared<BrokerState>(std::move(config), cqs);
|
||||
|
||||
|
@ -1812,26 +1736,4 @@ void Manager::PrepareForwarding(const std::string& name) {
|
|||
DBG_LOG(DBG_BROKER, "Resolved table forward for data store %s", name.c_str());
|
||||
}
|
||||
|
||||
void Manager::SetMetricsExportInterval(double value) {
|
||||
using dbl_seconds = std::chrono::duration<double>;
|
||||
auto ts = std::chrono::duration_cast<broker::timespan>(dbl_seconds{value});
|
||||
bstate->endpoint.metrics_exporter().set_interval(ts);
|
||||
}
|
||||
|
||||
void Manager::SetMetricsExportTopic(std::string value) {
|
||||
bstate->endpoint.metrics_exporter().set_target(std::move(value));
|
||||
}
|
||||
|
||||
void Manager::SetMetricsImportTopics(std::vector<std::string> topics) {
|
||||
bstate->endpoint.metrics_exporter().set_import_topics(std::move(topics));
|
||||
}
|
||||
|
||||
void Manager::SetMetricsExportEndpointName(std::string value) {
|
||||
bstate->endpoint.metrics_exporter().set_id(std::move(value));
|
||||
}
|
||||
|
||||
void Manager::SetMetricsExportPrefixes(std::vector<std::string> filter) {
|
||||
bstate->endpoint.metrics_exporter().set_prefixes(std::move(filter));
|
||||
}
|
||||
|
||||
} // namespace zeek::Broker
|
||||
|
|
|
@ -377,42 +377,6 @@ public:
|
|||
~ScriptScopeGuard() { --script_scope; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Changes the frequency for publishing scraped metrics to the target topic.
|
||||
* Passing a zero-length interval has no effect.
|
||||
* @param value Interval between two scrapes in seconds.
|
||||
*/
|
||||
void SetMetricsExportInterval(double value);
|
||||
|
||||
/**
|
||||
* Sets a new target topic for the metrics. Passing an empty string has no
|
||||
* effect.
|
||||
* @param value The new topic for publishing local metrics to.
|
||||
*/
|
||||
void SetMetricsExportTopic(std::string value);
|
||||
|
||||
/**
|
||||
* Sets the import topics for a node importing metrics.
|
||||
*
|
||||
* @param topics List of topics from which to import metrics.
|
||||
*/
|
||||
void SetMetricsImportTopics(std::vector<std::string> topics);
|
||||
|
||||
/**
|
||||
* Sets a new ID for the metrics exporter. Passing an empty string has no
|
||||
* effect.
|
||||
* @param value The new ID of the exporter in published metrics.
|
||||
*/
|
||||
void SetMetricsExportEndpointName(std::string value);
|
||||
|
||||
/**
|
||||
* Sets a prefix selection for the metrics exporter. An empty vector selects
|
||||
* *all* metrics.
|
||||
* @param filter List of selected metric prefixes or an empty vector for
|
||||
* selecting all metrics.
|
||||
*/
|
||||
void SetMetricsExportPrefixes(std::vector<std::string> filter);
|
||||
|
||||
private:
|
||||
// Process events used for Broker store backed zeek tables
|
||||
void ProcessStoreEvent(broker::data msg);
|
||||
|
|
|
@ -178,59 +178,3 @@ function Broker::__node_id%(%): string
|
|||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
return zeek::make_intrusive<zeek::StringVal>(broker_mgr->NodeID());
|
||||
%}
|
||||
|
||||
function Broker::__set_metrics_export_interval%(value: interval%): bool
|
||||
%{
|
||||
// This BIF may run prior to broker::Manager::InitPostScript. In this case,
|
||||
// broker_mgr is still null but we can safely ignore this event because the
|
||||
// Manager is going to initialize Broker using the most recent value of the
|
||||
// corresponding option.
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
if ( broker_mgr )
|
||||
broker_mgr->SetMetricsExportInterval(value);
|
||||
return zeek::val_mgr->True();
|
||||
%}
|
||||
|
||||
function Broker::__set_metrics_export_topic%(value: string%): bool
|
||||
%{
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
if ( broker_mgr )
|
||||
broker_mgr->SetMetricsExportTopic(value->ToStdString());
|
||||
return zeek::val_mgr->True();
|
||||
%}
|
||||
|
||||
function Broker::__set_metrics_import_topics%(filter: string_vec%): bool
|
||||
%{
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
if ( broker_mgr )
|
||||
{
|
||||
std::vector<std::string> slist;
|
||||
auto* vval = filter->AsVectorVal();
|
||||
for ( unsigned index = 0; index < vval->Size(); ++index )
|
||||
slist.emplace_back(vval->StringValAt(index)->ToStdString());
|
||||
broker_mgr->SetMetricsImportTopics(std::move(slist));
|
||||
}
|
||||
return zeek::val_mgr->True();
|
||||
%}
|
||||
|
||||
function Broker::__set_metrics_export_endpoint_name%(value: string%): bool
|
||||
%{
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
if ( broker_mgr )
|
||||
broker_mgr->SetMetricsExportEndpointName(value->ToStdString());
|
||||
return zeek::val_mgr->True();
|
||||
%}
|
||||
|
||||
function Broker::__set_metrics_export_prefixes%(filter: string_vec%): bool
|
||||
%{
|
||||
zeek::Broker::Manager::ScriptScopeGuard ssg;
|
||||
if ( broker_mgr )
|
||||
{
|
||||
std::vector<std::string> slist;
|
||||
auto* vval = filter->AsVectorVal();
|
||||
for ( unsigned index = 0; index < vval->Size(); ++index )
|
||||
slist.emplace_back(vval->StringValAt(index)->ToStdString());
|
||||
broker_mgr->SetMetricsExportPrefixes(std::move(slist));
|
||||
}
|
||||
return zeek::val_mgr->True();
|
||||
%}
|
||||
|
|
|
@ -32,10 +32,6 @@ void Manager::InitPostScript() {
|
|||
prometheus_url = util::fmt("localhost:%s", env);
|
||||
else {
|
||||
auto metrics_port = id::find_val("Telemetry::metrics_port")->AsPortVal();
|
||||
if ( metrics_port->Port() == 0 )
|
||||
// Remove this in v7.1 when the Broker variables are removed
|
||||
metrics_port = id::find_val("Broker::metrics_port")->AsPortVal();
|
||||
|
||||
if ( metrics_port->Port() != 0 )
|
||||
prometheus_url = util::fmt("localhost:%u", metrics_port->Port());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue