How could I pass output of to_json() from nxlog.conf to perl file?

Tags: xm_perl | json | nxlog | Perl

#1 EZ

Hi, I have this type of input in nxlog.conf:

<Input udp>
    Module      im_udp
    Host        0.0.0.0
    Port        514
    Exec        parse_syslog(); to_json(); perl_call("process");
</Input>

My question is, how should I include that JSON output that I get from to_json() to my perl code? Should I write like this?:

my ( $event ) = @_;

Or it's only the output of parse_syslog_bsd() (as in example for xm_perl https://nxlog.co/documentation/nxlog-user-guide/xm_perl.html)? More generally, my question is how to include JSON output that i get from to_json() to perl code of xm_perl module?

#2 b0ti Nxlog ✓
#1 EZ
Hi, I have this type of input in nxlog.conf: <Input udp> Module im_udp Host 0.0.0.0 Port 514 Exec parse_syslog(); to_json(); perl_call("process"); </Input> My question is, how should I include that JSON output that I get from to_json() to my perl code? Should I write like this?: my ( $event ) = @_; Or it's only the output of parse_syslog_bsd() (as in example for xm_perl https://nxlog.co/documentation/nxlog-user-guide/xm_perl.html)? More generally, my question is how to include JSON output that i get from to_json() to perl code of xm_perl module?

to_json() puts the result in the $raw_event field. You can access that from perl via the following:

my ( $event ) = @_;

my $json = Log::Nxlog::get_field($event, 'raw_event');