pdmorrow/journalstat

Option to match only the first n chars

Closed this issue · 4 comments

hprem commented

Is it possible to match only the first n chars, along with --top-talkers <top-talkers> parameter.

For example, if there are messages of this format in the journal

[my_process] Value of i = 1
[my_process] Value of i = 2
[my_process] Value of i = 3
...
[my_process] Value of i = 50

Then
sudo ./journalstat -i journal --top-talkers 1 --char-limit 26 | grep -A10 ^Top should report

Top 3 most frequent messages:
+------+-----------+------------+----------+-------------------------------+
| Rank | Frequency | Process    | Priority | Message                       |
+------+-----------+------------+----------+-------------------------------+
| 1    | 50        | vpp-driver | debug    | [my_process] Value of i = ... |
+------+-----------+------------+----------+-------------------------------+

Sure, I can do this.

hprem commented

Even better if you can add support for matching substrings or even a regex pattern (but I think, it might make journalstat much slower) :-)

Even better if you can add support for matching substrings or even a regex pattern (but I think, it might make journalstat much slower) :-)

@hprem Regex support added via #2

The --pattern option takes a regex, and if that regex has a match in the journal message it is counted in the statistics.

hprem commented

Thanks @pdmorrow