mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00

- On-demand access to sumstats results through "return from" functions named SumStats::request and Sumstats::request_key. Both functions are tested in standalone and clustered modes. - $name field has returned to SumStats which simplifies cluster code and makes the on-demand access stuff possible. - Clustered results can only be collected for 1 minute from their time of creation now instead of time of last read. - Thresholds use doubles instead of counts everywhere now. - Calculation dependency resolution occurs at start up time now instead of doing it at observation time which provide a minor cpu performance improvement. A new plugin registration mechanism was created to support this change. - AppStats now has a minimal doc string and is broken into hook-based plugins. - AppStats and traceroute detection added to local.bro
35 lines
1.6 KiB
Text
35 lines
1.6 KiB
Text
# @TEST-EXEC: bro %INPUT
|
|
# @TEST-EXEC: btest-diff .stdout
|
|
|
|
event bro_init() &priority=5
|
|
{
|
|
local r1: SumStats::Reducer = [$stream="test.metric",
|
|
$apply=set(SumStats::SUM,
|
|
SumStats::VARIANCE,
|
|
SumStats::AVERAGE,
|
|
SumStats::MAX,
|
|
SumStats::MIN,
|
|
SumStats::STD_DEV,
|
|
SumStats::UNIQUE)];
|
|
SumStats::create([$name="test",
|
|
$epoch=3secs,
|
|
$reducers=set(r1),
|
|
$epoch_finished(data: SumStats::ResultTable) =
|
|
{
|
|
for ( key in data )
|
|
{
|
|
local r = data[key]["test.metric"];
|
|
print fmt("Host: %s - num:%d - sum:%.1f - var:%.1f - avg:%.1f - max:%.1f - min:%.1f - std_dev:%.1f - unique:%d", key$host, r$num, r$sum, r$variance, r$average, r$max, r$min, r$std_dev, r$unique);
|
|
}
|
|
}
|
|
]);
|
|
|
|
SumStats::observe("test.metric", [$host=1.2.3.4], [$num=5]);
|
|
SumStats::observe("test.metric", [$host=1.2.3.4], [$num=22]);
|
|
SumStats::observe("test.metric", [$host=1.2.3.4], [$num=94]);
|
|
SumStats::observe("test.metric", [$host=1.2.3.4], [$num=50]);
|
|
SumStats::observe("test.metric", [$host=1.2.3.4], [$num=50]);
|
|
|
|
SumStats::observe("test.metric", [$host=6.5.4.3], [$num=2]);
|
|
SumStats::observe("test.metric", [$host=7.2.1.5], [$num=1]);
|
|
}
|