Skip to content

Commit af109f0

Browse files
committed
Merge branch 'master' of github.com:/mmguero-dev/json-streaming-logs
* 'master' of github.com:/mmguero-dev/json-streaming-logs: make enabled_logs filter a set of log streams, not strings Added new test for enabled_files add enabled_logs variable to control which logs get the json_streaming_ treatment add enabled_logs variable to control which logs get the json_streaming_ treatment add enabled_logs variable to control which logs get the json_streaming_ treatment
2 parents e61088a + 77f7a51 commit af109f0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

scripts/main.zeek

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ export {
2727
## JSON streaming logs. This is set separately since these logs are ephemeral
2828
## and meant to be immediately carried off to some other storage and search system.
2929
const JSONStreaming::rotation_interval = 15mins &redef;
30+
31+
## Set of log streams to get the json_streaming_ treatment. If empty, do all logs.
32+
const JSONStreaming::enabled_logs: set[Log::ID] = set() &redef;
3033
}
3134

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

8891
for ( stream in Log::active_streams )
8992
{
93+
# Skip this filter if it's not in the enabled set (unless enabled_logs is empty)
94+
if ( |JSONStreaming::enabled_logs| > 0 && !(stream in JSONStreaming::enabled_logs) )
95+
next;
96+
9097
for ( filter_name in Log::get_filter_names(stream) )
9198
{
9299
# This is here because we're modifying the list of filters right now...

testing/tests/logs-filtered.zeek

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# @TEST-DOC: Verifies that Zeek by default writes both the usual logs and the (filtered) json-streaming ones.
2+
# @TEST-EXEC: zeek -r $TRACES/http.pcap $PACKAGE %INPUT
3+
# @TEST-EXEC: for f in conn files http packet_filter; do test -f $f.log; done
4+
# @TEST-EXEC: for f in files http; do test -f json_streaming_$f.log; done
5+
# @TEST-EXEC: for f in conn packet_filter; do ! test -f json_streaming_$f.log; done
6+
7+
# Filter the list of files
8+
redef JSONStreaming::enabled_logs = set(HTTP::LOG, Files::LOG);
9+
# Turn off log rotation handling because it only kicks in for some of the files:
10+
redef JSONStreaming::enable_log_rotation = F;

0 commit comments

Comments
 (0)