Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions scripts/main.zeek
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export {
## JSON streaming logs. This is set separately since these logs are ephemeral
## and meant to be immediately carried off to some other storage and search system.
const JSONStreaming::rotation_interval = 15mins &redef;

## Set of log streams to get the json_streaming_ treatment. If empty, do all logs.
const JSONStreaming::enabled_logs: set[Log::ID] = set() &redef;
}

type JsonStreamingExtension: record {
Expand Down Expand Up @@ -87,6 +90,10 @@ event zeek_init() &priority=-5

for ( stream in Log::active_streams )
{
# Skip this filter if it's not in the enabled set (unless enabled_logs is empty)
if ( |JSONStreaming::enabled_logs| > 0 && !(stream in JSONStreaming::enabled_logs) )
next;

for ( filter_name in Log::get_filter_names(stream) )
{
# This is here because we're modifying the list of filters right now...
Expand Down
10 changes: 10 additions & 0 deletions testing/tests/logs-filtered.zeek
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# @TEST-DOC: Verifies that Zeek by default writes both the usual logs and the (filtered) json-streaming ones.
# @TEST-EXEC: zeek -r $TRACES/http.pcap $PACKAGE %INPUT
# @TEST-EXEC: for f in conn files http packet_filter; do test -f $f.log; done
# @TEST-EXEC: for f in files http; do test -f json_streaming_$f.log; done
# @TEST-EXEC: for f in conn packet_filter; do ! test -f json_streaming_$f.log; done

# Filter the list of files
redef JSONStreaming::enabled_logs = set(HTTP::LOG, Files::LOG);
# Turn off log rotation handling because it only kicks in for some of the files:
redef JSONStreaming::enable_log_rotation = F;
Loading