| 1 |
Grok Message Modify Plugin |
| 2 |
|
| 3 |
Using hundreds of grok patterns from logstash-patterns-core. |
| 4 |
|
| 5 |
Build |
| 6 |
|
| 7 |
This plugin requires libfastjson (always present in rsyslog core), glib2, and grok packages. |
| 8 |
|
| 9 |
If you use RH/CentOS/Fedora, you'll have to build grok rpms by yourself as follow: |
| 10 |
|
| 11 |
sudo yum install -y yum-utils rpmdevtools |
| 12 |
git clone [email protected]:jordansissel/grok.git |
| 13 |
mkdir -p ~/rpmbuild/SPECS/; cp grok/grok.spec.template ~/rpmbuild/SPECS/grok.spec |
| 14 |
(mkdir -p ~/rpmbuild/SOURCES/; cd ~/rpmbuild/SOURCES/; spectool -g ../SPECS/grok.spec) |
| 15 |
sudo yum-builddep ~/rpmbuild/SPECS/grok.spec |
| 16 |
rpmbuild -bb ~/rpmbuild/SPECS/grok.spec |
| 17 |
# use yum command instead of rpm, because grok depends on libevent, pcre, tokyocabinet |
| 18 |
sudo yum install -y libjson-c-devel glib2-devel ~/rpmbuild/RPMS/x86_64/grok*.rpm |
| 19 |
|
| 20 |
Example |
| 21 |
|
| 22 |
module(load="mmgrok") |
| 23 |
template(name="tmlp" type="string" string="%$!msg!test%\n") |
| 24 |
action(type="mmgrok" patterndir="path/to/yourpatternsDir" match="%{WORD:test}" source="msg" target="!msg") |
| 25 |
action(type="omfile" file="path/to/file" template="tmlp") |
| 26 |
|
| 27 |
Description |
| 28 |
|
| 29 |
patterndir: path to grok patterns dir, default: /usr/share/grok/patterns/base |
| 30 |
match:the pattern used to match message |
| 31 |
source: the source message/variable to be matched |
| 32 |
target: the root path to write the captured json tree |