Skip to content

Commit d681e78

Browse files
committed
Rename filters to matches
I felt the term filters was being somewhat overloaded since fluentd also has a concept of filters. In the journalctl documentation these expressions are refered to as matches... so it seems resonable to do the same... The filters param will continue to work, with a warning...
1 parent 78bfdb2 commit d681e78

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

lib/fluent/plugin/in_systemd.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class SystemdInput < Input
1515
DEFAULT_STORAGE_TYPE = 'local'
1616

1717
config_param :path, :string, default: '/var/log/journal'
18-
config_param :filters, :array, default: []
18+
config_param :filters, :array, default: [], deprecated: 'filters has been renamed as matches'
19+
config_param :matches, :array, default: nil
1920
config_param :read_from_head, :bool, default: false
2021
config_param :tag, :string
2122

@@ -54,7 +55,7 @@ def init_journal
5455
# make sure initial call to wait doesn't return :invalidate
5556
# see https://github.com/ledbettj/systemd-journal/issues/70
5657
@journal.wait(0)
57-
@journal.filter(*@filters)
58+
@journal.filter(*(@matches || @filters))
5859
seek
5960
true
6061
rescue Systemd::JournalError => e

test/plugin/test_in_systemd.rb

+15-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ def setup
8383
filters [{ "_SYSTEMD_UNIT": "systemd-journald.service" }]
8484
)
8585

86+
@matches_config = @head_config + %(
87+
matches [{ "_SYSTEMD_UNIT": "systemd-journald.service" }]
88+
)
89+
8690
@tail_config = @storage_config + %(
8791
read_from_head false
8892
)
@@ -94,7 +98,7 @@ def setup
9498
end
9599

96100
attr_reader :journal, :base_config, :head_config,
97-
:filter_config, :tail_config, :not_present_config,
101+
:matches_config, :filter_config, :tail_config, :not_present_config,
98102
:badmsg_config, :storage_path, :storage_config
99103

100104
def create_driver(config)
@@ -180,6 +184,7 @@ def test_backoff_on_buffer_error
180184
d.run(expect_emits: 1)
181185
end
182186

187+
# deprecated and replaced with matches
183188
def test_reading_with_filters
184189
d = create_driver(filter_config)
185190
d.end_if do
@@ -189,6 +194,15 @@ def test_reading_with_filters
189194
assert_equal 3, d.events.size
190195
end
191196

197+
def test_reading_with_matches
198+
d = create_driver(matches_config)
199+
d.end_if do
200+
d.events.size >= 3
201+
end
202+
d.run(timeout: 5)
203+
assert_equal 3, d.events.size
204+
end
205+
192206
def test_reading_from_a_pos
193207
write_pos 's=add4782f78ca4b6e84aa88d34e5b4a9d;i=13f;b=4737ffc504774b3ba67020bc947f1bc0;m=ffadd;t=4d905e49a6291;x=9a11dd9ffee96e9f'
194208
d = create_driver(head_config)

0 commit comments

Comments
 (0)