The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::Graylog::Client - Client for Graylog2 analysis server

VERSION

version 0.7

SYNOPSIS

  use Net::Graylog::Client ;
 
  my $log = Net::Graylog::Client->new( url => 'http://graylog.server:12002/gelf' ) ;

  $log->send( message => 'testing', level => 'debug') ;

DESCRIPTION

Send a message to a graylog2 analysis server

You may send any data to a gray log server, but there are some restrictions plus this module adds some defaults.

* There must be a message field * a level field will be interpreted as a syslog level and converted to a number * you can access the original value with the levelstr field * a datetime and timestr field are added, the former is a unix int timestamp, the latter a time string * each message gets a uuid * a server field will be reinterpreseted as a host field, a default of hostname() will be added if needed

NAME

Net::Graylog::Client - Client for Graylog2 analysis server

VERSION

version 0.7

NAME

Net::Graylog::Client

AUTHOR

 kevin mulholland

VERSIONS

v0.1 2014/03/19, initial work

Notes

Obviously if you just want oto do this on the command line you can use

curl -XPOST http://graylog2_server:12202/gelf -p0 -d '{"short_message":"Hello there", "host":"example.org", "facility":"test", "_foo":"bar"}'

See Also

Log::Log4perl::Layout::GELF , Net::Sentry::Client

Todo

Investigate HTTP::Async instead of :Furl as it will not block, so we can wait for the response to be received, rather than the timeout to lapse

Public Functions

new

Create a new instance of the logger

    my $log = Net::Graylog::Client->new( url => 'http://graylog2_server:12202/gelf') ;

Parameters url the url of the graylog server, of the form http://graylog2_server:12202/gelf timeout, can be a float, default 0.01, Furl seems to wait until the timeout occurs before giving a response, which really cuts into the speed of sending, you may want to make this bigger for non-local servers, ie 1s

send

send a hash of data to the graylog server

    my $log = Net::Graylog::Client->new( 'http://graylog2_server:12202/gelf') ;
    $log->send( message => 'test message', level => 'info', elapsed = 12.1 )

Any data that is in the hash is passed to the server, though some may be re-interpreted as mentioned in the DESCRIPTION

Parameters hash of data to send

B><Returns> status - true = Sent, false = Failed code - HTTP response code from the graylog server

emerg alert crit error warning notice info debug

short cut to send, setting the syslog level to the name of the method

    my $log = Net::Graylog::Client->new( 'http://graylog2_server:12202/gelf') ;
    # level = alert
    $log->alert( message => 'test message', elapsed = 12.1 )
    # level = debug
    $log->debug( message => 'test message', elapsed = 12.1 )

Any data that is in the hash is passed to the server, though some may be re-interpreted as mentioned in the DESCRIPTION

The level field is overwritten with the name of the method called

Parameters hash of data to send

B><Returns> status - true = Sent, false = Failed code - HTTP response code from the graylog server

valid_levels

returns a list of the valid syslog levels

valid_facilities

returns a list of the valid syslog facilies

AUTHOR

Kevin Mulholland <moodfarm@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Kevin Mulholland.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

AUTHOR

Kevin Mulholland <moodfarm@cpan.org> James Lavoy <jalavoy@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Kevin Mulholland.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.