Blog

Filtering file names on the client-side

The Logentries agent enables users to get set up very quickly. One of the reasons we provide it is for convenience, as using the agent is far easier than configuring similar tools like syslog.

To achieve that, the agent loads the latest configuration from Logentries on every start. Some users expressed concerns about this behavior. For example, should their account on Logentries be compromised, users had asked if one could potentially enable the agent to monitor other logs on their system – note the agent would not be able to upload a full history of system log files, as the agent sends deltas of growing files only.

However, we understand this concern. In order to reduce these concerns, and in cases where other options like rsyslog and syslog-ng are not suitable, we have extended the agent to support client-side file name filtering. Whenever the agent loads a new configuration it passes all files to be followed to a user-provided filter. Only files which pass this test are monitored.

Defining your own filter is easy – just provide a filtering function filter_filename which will return “True” or “False,” depending on if the agent is allowed to follow the file or not.

Typically you create a new directory that contains the filtering code. Create an empty __init__.py file there and in filters.py define the function filter_filtername. For example, the filters.py may contain this code to allow following log files only:

1
2
def filter_filename( filename):
    return filename.endswith( '.log')

The last step is to let the agent know where to look for the filter. In the agent configuration file (~/.le/config or /root/le/config) define filter option pointing to a directory containing your filter. For example:

1
filters=/path/to/filters

Then restart the agent. That’s it!

Note that for large installation bases we also recommend using some modern syslog variant like rsyslog and syslog-ng which are commonly installed on Linux boxes. You won’t need to install additional software and given 128 bit long token and SSL support it provides a comparable level of security as the agent does.


Want to start using this feature to get the Logentries agent managing logs for your application? Sign up here and get started on your free 30-day trial account.


Share This Post


Viliam is a co-founder and in a position that could be called CTO.

Posted in Agent, Feature

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <p>

Current day month ye@r *