Net::Graylog::Client - Client for Graylog2 analysis server
version 0.7
use Net::Graylog::Client ; my $log = Net::Graylog::Client->new( url => 'http://graylog.server:12002/gelf' ) ; $log->send( message => 'testing', level => 'debug') ;
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
Net::Graylog::Client
kevin mulholland
v0.1 2014/03/19, initial work
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"}'
Log::Log4perl::Layout::GELF , Net::Sentry::Client
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
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 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
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 )
The level field is overwritten with the name of the method called
returns a list of the valid syslog levels
returns a list of the valid syslog facilies
Kevin Mulholland <moodfarm@cpan.org>
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.
Kevin Mulholland <moodfarm@cpan.org> James Lavoy <jalavoy@cpan.org>
This software is copyright (c) 2017 by Kevin Mulholland.
To install Net::Graylog::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Graylog::Client
CPAN shell
perl -MCPAN -e shell install Net::Graylog::Client
For more information on module installation, please visit the detailed CPAN module installation guide.