mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00

- Removed default logging. Now a function is available for the new $period_finished filter field to get the same behavior for logging named Metrics::write_log. - Added index rollups for getting multiple metrics result values as the same time.
37 lines
902 B
Text
37 lines
902 B
Text
@load ./main
|
|
|
|
module Metrics;
|
|
|
|
event Metrics::finish_period(filter: Filter)
|
|
{
|
|
local data = store[filter$id, filter$name];
|
|
if ( filter?$rollup )
|
|
{
|
|
for ( index in data )
|
|
{
|
|
if ( index !in rollup_store )
|
|
rollup_store[index] = table();
|
|
rollup_store[index][filter$id, filter$name] = data[index];
|
|
|
|
# If all of the result vals are stored then the rollup callback can be executed.
|
|
if ( |rollup_store[index]| == |rollups[filter$rollup]$filters| )
|
|
{
|
|
rollups[filter$rollup]$callback(index, rollup_store[index]);
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( filter?$period_finished )
|
|
filter$period_finished(network_time(), filter$id, filter$name, data);
|
|
|
|
reset(filter);
|
|
|
|
schedule filter$every { Metrics::finish_period(filter) };
|
|
}
|
|
|
|
|
|
function data_added(filter: Filter, index: Index, val: ResultVal)
|
|
{
|
|
if ( check_thresholds(filter, index, val, 1.0) )
|
|
threshold_crossed(filter, index, val);
|
|
}
|