| 1 |
NAME |
| 2 |
Message::Passing::Filter::Regexp - Regexp Capture Filter For |
| 3 |
Message::Passing |
| 4 |
|
| 5 |
SYNOPSIS |
| 6 |
# regexfile |
| 7 |
*** FORMAT *** |
| 8 |
:default = "%date %status %remotehost %domain %request %originhost %responsetime %upstreamtime %bytes %referer %ua %xff" |
| 9 |
:nginxaccesslog = "%date %status %remotehost %bytes %responsetime" |
| 10 |
*** REGEXP *** |
| 11 |
%date = '(?#=date)\[(?#=ts)\d{2}\/\w{3}\/\d{4}(?::\d{2}){3}(?#!ts) [-+]\d{4}\](?#!date)' |
| 12 |
%status = '(?#=status)\d+(?#!status)' |
| 13 |
%remotehost = '(?#=remotehost)\S+(?#!remotehost)' |
| 14 |
%domain = '(?#=domain).*?(?#!domain)' |
| 15 |
%request = '(?#=request)-|(?#=method)\w+(?#!method) (?#=url).*?(?#!url) (?#=version)HTTP/\d\.\d(?#!version)(?#!request)' |
| 16 |
%originhost = '(?#=originhost)-|(?#=oh).*?(?#!oh):\d+(?#!originhost)' |
| 17 |
%responsetime = '(?#=responsetime)-|.*?(?#!responsetime)' |
| 18 |
%upstreamtime = '(?#=upstreamtime).*?(?#!upstreamtime)' |
| 19 |
%bytes = '(?#=bytes)\d+(?#!bytes)' |
| 20 |
%referer = '(?#=referer)\"(?#=ref).*?(?#!ref)\"(?#!referer)' |
| 21 |
%useragent = '(?#=useragent)\"(?#=ua).*?(?#!ua)\"(?#!useragent)' |
| 22 |
%xforwarderfor = '(?#=xforwarderfor)\"(?#=xff).*?(?#!xff)\"(?#!xforwarderfor)' |
| 23 |
|
| 24 |
# message-passing-cli |
| 25 |
use Message::Passing::DSL; |
| 26 |
run_message_server message_chain { |
| 27 |
input file => ( |
| 28 |
class => 'FileTail', |
| 29 |
output_to => 'decoder', |
| 30 |
); |
| 31 |
decoder decoder => ( |
| 32 |
class => 'JSON', |
| 33 |
output_to => 'logstash', |
| 34 |
); |
| 35 |
filter logstash => ( |
| 36 |
class => 'ToLogstash', |
| 37 |
output_to => 'regexp', |
| 38 |
); |
| 39 |
filter regexp => ( |
| 40 |
class => 'Regexp', |
| 41 |
format => ':nginxaccesslog', |
| 42 |
capture => [qw( ts status remotehost url oh responsetime upstreamtime bytes )] |
| 43 |
output_to => 'encoder', |
| 44 |
); |
| 45 |
encoder("encoder", |
| 46 |
class => 'JSON', |
| 47 |
output_to => 'stdout', |
| 48 |
output_to => 'es', |
| 49 |
); |
| 50 |
output stdout => ( |
| 51 |
class => 'STDOUT', |
| 52 |
); |
| 53 |
output elasticsearch => ( |
| 54 |
class => 'ElasticSearch', |
| 55 |
elasticsearch_servers => ['127.0.0.1:9200'], |
| 56 |
); |
| 57 |
}; |
| 58 |
|
| 59 |
DESCRIPTION |
| 60 |
This filter passes all incoming messages through with regexp captures. |
| 61 |
Note it must be running after Message::Passing::Filter::ToLogstash |
| 62 |
because it don't process with json format but directly capture |
| 63 |
"$message->{'@message'}" data lines into "%{ $message->{'@fields'} }" |
| 64 |
|
| 65 |
ATTRIBUTES |
| 66 |
regexfile |
| 67 |
Path of your regexfile. Default is /etc/message-passing/regexfile. |
| 68 |
|
| 69 |
format |
| 70 |
Name of a defined format in your regexfile. |
| 71 |
|
| 72 |
capture |
| 73 |
ArrayRef of regex names which you want to capture and has been defined |
| 74 |
in your regexfile. note delete the prefix "%". |
| 75 |
|
| 76 |
SEE ALSO |
| 77 |
Capture Idea steal from <http://logstash.net> Grok filter Config Format |
| 78 |
steal from <http://oss.oetiker.ch/smokeping> use Config::Grammar |
| 79 |
|
| 80 |
AUTHOR |
| 81 |
chenryn, <[email protected]> |
| 82 |
|
| 83 |
COPYRIGHT AND LICENSE |
| 84 |
Copyright (C) 2012 by chenryn |
| 85 |
|
| 86 |
This library is free software; you can redistribute it and/or modify it |
| 87 |
under the same terms as Perl itself, either Perl version 5.14.2 or, at |
| 88 |
your option, any later version of Perl 5 you may have available. |
| 89 |
|