Fluentd plugin to filter records with SQL-like WHERE statements
See .travis.yml
fluent-plugin-filter_where
supports both v0.14 API and v0.12 API in one gem.
Use RubyGems:
gem install fluent-plugin-filter_where
-
where
The SQL-like WHERE statements. See SQL-like Syntax for more details.
<filter foo.**>
@type where
where string_key = 'string' OR number_key >= 0.1
</filter>
Example:
where (string_key START_WITH 'str' AND number_key > 1.0) OR ("true_key" = true AND NOT (string_key REGEXP '^reg'))
true
or TRUE
or false
or FALSE
are considered as a boolean literal
Characters matching with a regular expression -?[0-9]+(\.[0-9]+)?
is considered as a number literal
Characters surrounded by '
such as 'foo'
is considered as a string literal
Not supported yet
Characters matching with a regular expression [a-zA-Z_][a-zA-z0-9_]*
such as foobar
, and characters surrounded by "
such as "foo-bar"
, "foo.bar"
, and "foo\"bar"
are considred as an identifier literal, that is, fluentd's record key name.
=
: Equal operator!=
,<>
: Not equal operator
=
: Equal operator!=
,<>
: Not equal operator>
: Greater than operator>=
: Greater than or equal operator<=
: Less than or equal operator<
: Less than operator
=
: Equal operator!=
,<>
: Not equal operatorSTART_WITH
END_WITH
INCLUDE
REGEXP
Not supported yet
NOT xxx
IS NULL
IS NOT NULL
See CHANGELOG.md for details.
Run test:
$ bundle exec rake test
Release:
Modify version.rb and CHANGELOG.md, then
$ bundle exec rake release
This plugin uses rexical for lexical scanner generator, and racc for parser generator.
If you modify parser.rex
or parser.racc
, you must compile them as:
$ bundle exec rake compile
The test
task runs the compile
task before running.
- grep filter
- grep filter plugin is bundled in fluentd >= 0.12.
- I am the maintainor of the plugin, but I now feel where filter plugin is more useful.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Copyright (c) 2017 - Naotoshi Seo. See LICENSE for details.