ountersOutput::JSON;
use strict;
use warnings;
# ABSTRACT: plugin to dump counters in JSON format
our $VERSION = '1.6'; # VERSION
use base 'Log::Saftpresse::CountersOutput';
use JSON;
sub output
{
my ( $self, $counters ) = @_;
my $json = JSON->new;
$json->pretty(1);
my %data = map {
$_ => $counters->{$_}->counters,
} keys %$counters;
print $json->encode( \%data );
return;
}
1;
__E
ND__
=pod
=encoding UTF-8
=head1 NAME
Log::Saftpresse::CountersOutput::JSON - plugin to dump counters in JSON format
=head1 VERSION
version 1.6
=head1 AUTHOR
Markus Benning <ich@markusbenning.
Output::JSON;
use Moose;
# ABSTRACT: plugin to dump events to in JSON to stdout
our $VERSION = '1.6'; # VERSION
extends 'Log::Saftpresse::Output';
has 'json' => (
is => 'ro', isa => 'JSON', lazy
=> 1,
default => sub {
my $j = JSON->new;
$j->utf8(1); $j->pretty(1); $j->allow_blessed(1);
return $j;
},
);
sub output {
my ( $self, @events ) = @_;
foreach my $event (@events) {
my %
->dump_json_data( \%output );
}
return;
}
sub _backend {
my $self = shift;
if( defined $self->{'_backend'} ) {
return $self->{'_backend'} ;
}
foreach my $module ( 'JSON::Color', 'JSON') {
rs => {
module => 'Dump',
},
),
Output => ordered_hash_ref (
dump_json => {
module => 'JSON',
},
),
);
return \%defaults;
},
);
has 'config' => ( is => 'rw' );
su
s 'Log::Saftpresse::CountersOutput';
use Log::Saftpresse::Utils qw( adj_int_units get_smh);
use JSON;
use Time::Piece;
use Template;
use Template::Stash;
$Template::Stash::LIST_OPS->{ type } = sub
}
return( $self->{_tt} );
}
sub json {
my $self = shift;
if( ! defined $self->{_json} ) {
$self->{_json} = JSON->new->pretty->utf8;
}
return( $self->{_json} );
}
sub template_content {
my
le="width:100%;height:300px"></div>
<script>
$( document ).ready(function() {
var data = [% self.json.encode( series ) %];
var options = {
series: {
stack: 1,
lines: {
show: true,
},
unters to stdout
our $VERSION = '1.6'; # VERSION
extends 'Log::Saftpresse::CountersOutput';
use JSON;
use Data::Dumper;
use Sys::Hostname;
has 'format' => ( is => 'rw', isa => 'Str', default => 'gr
eq 'graphit' ) {
$self->_output_graphit( \%data );
} elsif ( lc $self->format eq 'json' ) {
$self->_output_json( \%data );
} elsif ( lc $self->format eq 'perl' ) {
$self->_output_perl( \%data
) = @_;
print Dumper( $data );
return;
}
sub _output_json {
my ( $self, $data ) = @_;
my $json = JSON->new;
$json->pretty(1);
print $json->encode( $data );
return;
}
1;
__END__
=pod
=enc
gin::Role::Tracking';
use Log::Saftpresse::Log4perl;
use JSON;
has 'json' => (
is => 'ro', isa => 'JSON', lazy => 1,
default => sub { JSON->new; },
);
has 'test_stats' => ( is => 'ro', isa => 'Bo
tash->{'message'} = $msg;
}
# if JSON logging is configured decode JSON
if( $stash->{'message'} =~ /^{/ ) {
my $json_data;
eval {
$json_data = $self->json->decode( $stash->{'message'} );
rn('error while parsing amavis JSON log message: '.$@);
return;
}
if( ref($json_data) ne 'HASH' ) {
return;
}
@$stash{keys %$json_data} = values %$json_data;
}
if( ! defined $sta
queue
our $VERSION = '1.6'; # VERSION
extends 'Log::Saftpresse::Input';
use Redis;
use JSON qw(decode_json);
has 'server' => ( is => 'ro', isa => 'Str',
default => '127.0.0.1:6379'
);
has 'sock'
it_all_responses;
foreach my $entry ( grep { defined $_ } @queue ) {
push( @events, decode_json($entry) );
}
return @events;
}
sub eof {
my $self = shift;
return 0; # queues dont have an
h/to/socket"
db = 0
queue = "logs"
</Input>
=head1 Format
Format is expected to be in JSON format.
Each event must be a hash.
=head1 AUTHOR
Markus Benning <ich@markusbenning.de>
=head1
presse::Output';
use Log::Saftpresse::Log4perl;
use Time::Piece;
use Search::Elasticsearch;
use JSON;
use File::Slurp;
has 'nodes' => ( is => 'rw', isa => 'Str', default => 'localhost:9200' );
has
my $json_text;
if( defined $self->template_file ) {
$json_text = read_file( $self->template_file );
} else {
$json_text = read_file( \*DATA );
}
return( from_json( $json_te
server
our $VERSION = '1.6'; # VERSION
extends 'Log::Saftpresse::Output';
use Redis;
use JSON qw(encode_json);
has 'server' => ( is => 'ro', isa => 'Str',
default => '127.0.0.1:6379'
);
has 'soc
$output{'@timestamp'} = $output{'time'}->datetime;
delete $output{'time'};
}
encode_json(\%output)
} @events;
$self->_redis->lpush($self->queue, @blobs);
return;
}
1;
__END__
=po
socket"
db = 0
queue = "logs"
</Input>
=head1 Format
The plugin will write entries in JSON format.
=head1 AUTHOR
Markus Benning <ich@markusbenning.de>
=head1 COPYRIGHT AND LICENSE
This
r $VERSION = '1.6'; # VERSION
use JSON;
extends 'Log::Saftpresse::Input::Command';
has 'command' => ( is => 'ro', isa => 'Str', default => 'journalctl -f -o json');
has 'lowercase' => ( is => 'ro
isa => 'Bool', default => 1 );
sub process_line {
my ( $self, $line ) = @_;
my $data = from_json( $line );
if( $self->lowercase ) {
my %new = map { lc $_ => $data->{$_} } keys %$data;