[collectd] Negative lookahead/lookbehind

Brian Long brian at dotspots.com
Mon Jun 22 18:07:23 CEST 2009


Florian,

For my own use case, the simplest solution may be to simply allow for an
ExcludeRegex in addition to the (Include)Regex, with Exclude taking
priority. Of course, I am only looking for log entries that trip the
exception test, I am not trying to pull out any matching groups etc, or any
of the more complicated use cases or counter types. But an exclude regex
would be the path of least resistance for my use case (which I have to
imagine cannot be such a rare use case :^)

-B

On Sun, Jun 21, 2009 at 2:10 AM, Florian Forster <octo at verplant.org> wrote:

> Hi Brian,
>
> On Sat, Jun 20, 2009 at 10:51:28AM -0700, Brian Long wrote:
> > Does collectd support negative lookahead or lookbehind in regex's for
> > the tail plugin?
>
> the `tail' plugin and all other parts of collectd which use regular
> expressions use the extended POSIX regular expressions (sometimes also
> called “modern REs”). The syntax and features are described in the
> regex(7) manual page.
>
> > Lookbehind failure from logs:
> > Compiling the regular expression
> "(?<!IncompatibleRemoteService)Exception"
> > failed.
>
> Just so we're sure to talk about the same thing: You want to count all
> lines matching `Exception' except those that also match
> `IncompatibleRemoteServiceException'.
>
> > Lookahead failure from logs:
> > Compiling the regular expression "Exception(?!.*This application is
> > out of date)" failed.
>
> This is: All lines matching `Exception' except those also matching
> `Exception.*This application is out of date'.
>
> Neither syntax is included in the POSIX regexen and therefore not
> supported by the `tail' plugin or collectd in general.
>
> (Of course both cases are *theoretically* possible with the POSIX
> regular expressions, the theoretical reason being: “Regular languages
> are closed under complement and difference”. Unfortunately such insights
> are not helpful ;)
>
> We have thought about using the PCRE library for the tail plugin, but
> ultimately decided against it. If we use the library there, we should
> use it everywhere. We would therefore have a hard dependency on the
> library (something we definitely don't want) or we'd have differing
> behavior depending whether the daemon was built with or without the
> library. So in favor of consistent behavior all around we decided not to
> use PCRE.
>
> Maybe the following is a possibility to stay consistent and provide the
> features offered by PCRE at the same time: Introduce a configuration
> option, `RegexFlavor' that can be set to either `POSIX' or `PCRE'. If
> set to `PCRE', collectd (or the `tail' plugin) tries to load the `PCRE'
> library at runtime and uses it. This option could either be a global one
> (for all of collectd) or within the <Match /> blocks (then other plugins
> using those blocks, for example the `curl' plugin, would benefit as
> well). Any ideas?
>
> Regards,
> -octo
> --
> Florian octo Forster
> Hacker in training
> GnuPG: 0x91523C3D
> http://verplant.org/
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFKPfkMHdggu3Q05IYRAp35AJ0RSQHN5AukIcpNoF5n/++p3qPpAgCgn69A
> 2Ttv1SVA/Vft+GvKeadNVsc=
> =gsV9
> -----END PGP SIGNATURE-----
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.verplant.org/pipermail/collectd/attachments/20090622/f2e2a661/attachment.htm 


More information about the collectd mailing list