Skip to content

Commit ec7f967

Browse files
committed
Make it possible to filter on arbitrary journald fields
This commit adds a new option, journald_filters, which allows to pass a list of filters of the form <journald_field>=<value>. For a list of available journald fields, see: https://www.freedesktop.org/software/systemd/man/latest/systemd.journal-fields.html
1 parent c62e2ea commit ec7f967

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

README.rst

+7
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,13 @@ This feature requires latest version of ``python-systemd`` `with namespace suppo
326326
Require that the logs message matches only against certain _SYSTEMD_UNITs.
327327
If not set, we allow log events from all units.
328328

329+
``journald_filters`` (default ``[]``)
330+
331+
Journald filters in the form of <journald_field>=<value>. If not set, no filter will be applied.
332+
Example: SYSLOG_IDENTIFIER=postgres
333+
334+
Refer to https://www.freedesktop.org/software/systemd/man/latest/systemd.journal-fields.html for a list of valid fields.
335+
329336
``flags`` (default ``LOCAL_ONLY``)
330337

331338
``"LOCAL_ONLY"`` opens journal on local machine only; ``"RUNTIME_ONLY"`` opens only volatile journal files;

journalpump/journalpump.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,8 @@ def get_reader(self, seek_to=None, reinit=False):
468468

469469
for unit_to_match in self.config.get("units_to_match", []):
470470
self.journald_reader.add_match(_SYSTEMD_UNIT=unit_to_match)
471-
471+
for journald_filter in self.config.get("journald_filters", []):
472+
self.journald_reader.add_match(journald_filter)
472473
self.initialize_senders()
473474

474475
return self.journald_reader

0 commit comments

Comments
 (0)