Skip to content

Applying filters

Ralf Kilian edited this page Oct 2, 2020 · 5 revisions

Applying filters

Table of contents


Filter patterns

You can filter the output to e.g. only return lines that contain certain terms. There is also the optional --ignore-case argument to ignore the case of the given filter pattern. The filter pattern also allows spaces, including leading and trailing ones.

For example, to only return lines that contain the term error you can use the filter argument as follows:

./salomon.sh -a monitor -i /var/log/foobar.log -c /home/johndoe/foo_colors.cfg -f error

Als already mentioned, the pattern also allows spaces, but when using spaces the criteria must be enclosed either with single (') or double (") quotes, for example:

./salomon.sh -a monitor -i /var/log/foobar.log -c /home/johndoe/foo_colors.cfg -f "error while"

This will return lines that contain the term error while, but no lines which contain only one of those words. In case this does not work properly, you may try escaping the space (or all of them if there are multiple) using a backslash (\) like this:

./salomon.sh -a monitor -i /var/log/foobar.log -c /home/johndoe/foo_colors.cfg -f "error\ while"

Furthermore, the pattern allows multiple terms. These must be separated with semicolons and also be enclosed either with single (')or double (") quotes, for example:

./salomon.sh -a monitor -i /var/log/foobar.log -c /home/johndoe/foo_colors.cfg -f "error;warning;success"

This will return lines that contain at least one of those terms.

A combination of spaces and multiple terms inside the pattern also is supported:

./salomon.sh -a monitor -i /var/log/foobar.log -c /home/johndoe/foo_colors.cfg -f "error while;warning;success"

Top

Filter config files

Even though, the help output of the script returns that the filter argument expects a pattern, it is also possible to give a config file containing the pattern.

Inside the filters sub-directory there is a sample filter config file named sample_filter.cfg. This file contains usage examples how to filter the output.

For example, to use the file '/var/log/filter.cfg' as filter pattern execute the script as follows:

./salomon.sh -a monitor -i /var/log/foobar.log -c /home/johndoe/foo_colors.cfg -f /home/johndoe/filter.cfg

Please notice that in case the file does not exist, the script will interpret the given path as a pattern instead of a file path.

Top