Collector/Output/Socket/Logstash.pm

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 CC 1 SCAR 0.9
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Collector/Output/Socket/Base.pm ↑ Summary Collector/Output/Socket/OpenTSDB.pm »
1 package XAS::Collector::Output::Socket::Logstash;
2  
3 our $VERSION = '0.01';
4  
5 1 ▶use POE;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 use XAS::Class
9 0 ▶ debug => 0,
Subroutine BEGIN: called CC=1 SCAR=2.6
10 version => $VERSION,
11 base => 'XAS::Collector::Output::Socket::Base',
12 codec => 'JSON',
13 1 ;
14  
15 #use Data::Dumper;
16  
17 # ----------------------------------------------------------------------
18 # Public Events
19 # ----------------------------------------------------------------------
20  
21 sub store_data {
22 my ($self, $data, $ack, $input) = @_[OBJECT, ARG0...ARG2];
23  
24 my $alias = $self->alias;
25  
26 $self->log->debug("$alias: entering store_data()");
27 $self->log->debug("$alias: data type is " . ref($data));
28  
29 try {
30  
31 my $packet = encode($data);
32  
33 $poe_kernel->call($alias, 'write_data', $packet);
34 # $self->log->info_msg('send', $alias);
35  
36 } catch {
37  
38 my $ex = $_;
39  
40 $self->log->debug(Dumper($data));
41 $self->exception_handler($ex);
42  
43 };
44  
45 $poe_kernel->post($input, 'write_data', $ack);
46  
47 $self->log->debug("$alias: leaving store_data()");
48  
49 }
50  
51 # ----------------------------------------------------------------------
52 # Public Methods
53 # ----------------------------------------------------------------------
54  
55 # ----------------------------------------------------------------------
56 # Private Methods
57 # ----------------------------------------------------------------------
58  
59 1;
60  
61 __END__
62  
63 =head1 NAME
64  
65 XAS::Collector::Output:::Socket::Logstash - Send output to a logstash server
66  
67 =head1 SYNOPSIS
68  
69 use XAS::Collector::Output::Socket::Logstash;
70  
71 my $output = XAS::Collector::Output::Socket::Logstash->new(
72 -alias => 'output-logstash',
73 );
74  
75 =head1 DESCRIPTION
76  
77 This module will open and maintain a connection to a logstash server.
78  
79 =head1 METHODS
80  
81 =head2 new
82  
83 This module inherits from L<XAS::Collector::Output::Socket::Base|XAS::Collector::Output::Socket::Base>
84 and takes the same parameters.
85  
86 =head1 PUBLIC EVENTS
87  
88 =head2 store_data(OBJECT, ARG0...ARG2)
89  
90 This event will trigger the sending of packets to a logstash instance.
91  
92 =over 4
93  
94 =item B<OBJECT>
95  
96 A handle to the current object.
97  
98 =item B<ARG0>
99  
100 The data to be stored within the database.
101  
102 =item B<ARG1>
103  
104 The acknowledgement to send back to the message queue server.
105  
106 =item B<ARG2>
107  
108 The input to return the ack too.
109  
110 =back
111  
112 =head1 SEE ALSO
113  
114 =over 4
115  
116 =item L<XAS::Collector::Output::Socket::Base|XAS::Collector::Output::Socket::Base>
117  
118 =item L<XAS::Collector::Output::Socket::OpenTSDB|XAS::Collector::Output::Socket::OpenTSDB>
119  
120 =item L<XAS::Collector|XAS::Collector>
121  
122 =item L<XAS|XAS>
123  
124 =back
125  
126 =head1 AUTHOR
127  
128 Kevin L. Esteb, E<lt>kevin@kesteb.usE<gt>
129  
130 =head1 COPYRIGHT AND LICENSE
131  
132 Copyright (c) 2012-2015 Kevin L. Esteb
133  
134 This is free software; you can redistribute it and/or modify it under
135 the terms of the Artistic License 2.0. For details, see the full text
136 of the license at http://www.perlfoundation.org/artistic_license_2_0.
137  
138 =cut
« Collector/Output/Socket/Base.pm ↑ Summary Collector/Output/Socket/OpenTSDB.pm »