line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Saftpresse::Plugin::GraphitLineFormat; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1178
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: read metric values from logs and export them as counters |
6
|
|
|
|
|
|
|
our $VERSION = '1.5'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'Log::Saftpresse::Plugin'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Log::Saftpresse::Plugin::Role::CounterUtils'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub process { |
14
|
0
|
|
|
0
|
1
|
|
my ( $self, $event ) = @_; |
15
|
0
|
|
|
|
|
|
my $program = $event->{'program'}; |
16
|
0
|
0
|
0
|
|
|
|
if( ! defined $program || $program ne 'metric' ) { |
17
|
0
|
|
|
|
|
|
return; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my ( $path, $value, $ts ) = split(/\s+/, $event->{'message'}); |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
0
|
|
|
|
if( ! defined $path || $path !~ /^[a-zA-Z0-9\-_\.]+$/ ) { |
23
|
0
|
|
|
|
|
|
return; |
24
|
|
|
|
|
|
|
} |
25
|
0
|
0
|
0
|
|
|
|
if( ! defined $value || $value !~ /^[+\-]?[0-9,\.]+$/ ) { |
26
|
0
|
|
|
|
|
|
return; |
27
|
|
|
|
|
|
|
} |
28
|
0
|
0
|
0
|
|
|
|
if( ! defined $ts || $ts !~ /^\d+$/ ) { |
29
|
0
|
|
|
|
|
|
return; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
@$event{'type', 'path', 'value', 'timestamp'} = |
33
|
|
|
|
|
|
|
( 'metric', $path, $value, $ts ); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
return; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=pod |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=encoding UTF-8 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Log::Saftpresse::Plugin::GraphitLineFormat - read metric values from logs and export them as counters |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 VERSION |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
version 1.5 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 Description |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This plugin parses the graphit line format. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 Synopsis |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
<Plugin graphit> |
61
|
|
|
|
|
|
|
module = "GraphitLineFormat" |
62
|
|
|
|
|
|
|
</Plugin> |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 Input Format |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
The plugin expects a events with |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
'program' => 'metric' |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
and a 'message' field in graphit plaintext format: |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
'message' => '<metric path> <metric value> <metric timestamp>' |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 Output |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This plugin will add the following fields: |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=over |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item type |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
The value: 'metric'. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item path |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
The metric path. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item value |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
The metric value. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item timestamp |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
The metric timestamp. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHOR |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This software is Copyright (c) 1998 by James S. Seymour, 2015 by Markus Benning. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This is free software, licensed under: |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |