logstash-output-graphite 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -5
- data/README.md +3 -0
- data/lib/logstash/outputs/graphite.rb +23 -24
- data/logstash-output-graphite.gemspec +1 -1
- data/spec/outputs/graphite_spec.rb +2 -0
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b0fcc4d3ba4675e46b147a8e8fabd2fc24387c3
|
4
|
+
data.tar.gz: afb15d9df4d24266a16a05abe6dd9832360bc34a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e16bf4dd0736a352c1b44eeeee96cb229319a97132cd16ec26480536702f7b3d4c766b9c3747da3065ccd2a3f3425d62c97c243d922d78e0e7245153bccbcd6
|
7
|
+
data.tar.gz: 54d208eff8bfe710bef705cceb4b1faac4e0bdc56314187019e2c18deda14fe038054e695821b231b5f4978069c7d00f27be75e722e166a2ef15ffb79bd296bd
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
+
## 2.0.3
|
2
|
+
- Fixed empty/nil messages handling
|
3
|
+
|
1
4
|
## 2.0.0
|
2
|
-
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
5
|
+
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
3
6
|
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
4
7
|
- Dependency on logstash-core update to 2.0
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
## 1.0.2
|
10
|
+
- Added support for sprintf in field formatting
|
11
|
+
|
12
|
+
## 1.0.1
|
13
|
+
- Added support for nested hashes as values
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
+
[](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-graphite-unit/)
|
5
|
+
|
3
6
|
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
4
7
|
|
5
8
|
It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
|
@@ -30,7 +30,7 @@ class LogStash::Outputs::Graphite < LogStash::Outputs::Base
|
|
30
30
|
config :resend_on_failure, :validate => :boolean, :default => false
|
31
31
|
|
32
32
|
# The metric(s) to use. This supports dynamic strings like %{host}
|
33
|
-
# for metric names and also for values. This is a hash field with key
|
33
|
+
# for metric names and also for values. This is a hash field with key
|
34
34
|
# being the metric name, value being the metric value. Example:
|
35
35
|
# [source,ruby]
|
36
36
|
# metrics => { "%{host}/uptime" => "%{uptime_1m}" }
|
@@ -90,19 +90,18 @@ class LogStash::Outputs::Graphite < LogStash::Outputs::Base
|
|
90
90
|
end
|
91
91
|
|
92
92
|
connect
|
93
|
-
end
|
93
|
+
end
|
94
94
|
|
95
95
|
def connect
|
96
96
|
# TODO(sissel): Test error cases. Catch exceptions. Find fortune and glory. Retire to yak farm.
|
97
97
|
begin
|
98
98
|
@socket = TCPSocket.new(@host, @port)
|
99
99
|
rescue Errno::ECONNREFUSED => e
|
100
|
-
@logger.warn("Connection refused to graphite server, sleeping...",
|
101
|
-
:host => @host, :port => @port)
|
100
|
+
@logger.warn("Connection refused to graphite server, sleeping...", :host => @host, :port => @port)
|
102
101
|
sleep(@reconnect_interval)
|
103
102
|
retry
|
104
103
|
end
|
105
|
-
end
|
104
|
+
end
|
106
105
|
|
107
106
|
def construct_metric_name(event, metric)
|
108
107
|
if @metrics_format
|
@@ -113,41 +112,41 @@ class LogStash::Outputs::Graphite < LogStash::Outputs::Base
|
|
113
112
|
metric
|
114
113
|
end
|
115
114
|
|
116
|
-
public
|
117
115
|
def receive(event)
|
118
|
-
|
119
|
-
|
120
116
|
# Graphite message format: metric value timestamp\n
|
121
117
|
|
122
|
-
messages
|
123
|
-
|
124
|
-
|
118
|
+
# compact to remove nil messages which produces useless \n
|
119
|
+
messages = (
|
120
|
+
@fields_are_metrics \
|
121
|
+
? messages_from_event_fields(event, @include_metrics, @exclude_metrics)
|
122
|
+
: messages_from_event_metrics(event, @metrics)
|
123
|
+
).compact
|
125
124
|
|
126
125
|
if messages.empty?
|
127
|
-
@logger.debug("Message is empty, not sending anything to Graphite", :messages => messages, :host => @host, :port => @port)
|
126
|
+
@logger.debug? && @logger.debug("Message is empty, not sending anything to Graphite", :messages => messages, :host => @host, :port => @port)
|
128
127
|
else
|
129
128
|
message = messages.join("\n")
|
130
|
-
@logger.debug("Sending carbon messages", :messages => messages, :host => @host, :port => @port)
|
129
|
+
@logger.debug? && @logger.debug("Sending carbon messages", :messages => messages, :host => @host, :port => @port)
|
131
130
|
|
132
131
|
# Catch exceptions like ECONNRESET and friends, reconnect on failure.
|
133
132
|
# TODO(sissel): Test error cases. Catch exceptions. Find fortune and glory.
|
134
133
|
begin
|
135
134
|
@socket.puts(message)
|
136
135
|
rescue Errno::EPIPE, Errno::ECONNRESET, IOError => e
|
137
|
-
@logger.warn("Connection to graphite server died",
|
138
|
-
:exception => e, :host => @host, :port => @port)
|
136
|
+
@logger.warn("Connection to graphite server died", :exception => e, :host => @host, :port => @port)
|
139
137
|
sleep(@reconnect_interval)
|
140
138
|
connect
|
141
139
|
retry if @resend_on_failure
|
142
140
|
end
|
143
141
|
end
|
144
|
-
end
|
142
|
+
end
|
145
143
|
|
146
144
|
private
|
147
145
|
|
148
146
|
def messages_from_event_fields(event, include_metrics, exclude_metrics)
|
149
|
-
timestamp = event_timestamp(event)
|
150
147
|
@logger.debug? && @logger.debug("got metrics event", :metrics => event.to_hash)
|
148
|
+
|
149
|
+
timestamp = event_timestamp(event)
|
151
150
|
event.to_hash.flat_map do |metric,value|
|
152
151
|
next if EXCLUDE_ALWAYS.include?(metric)
|
153
152
|
next unless include_metrics.empty? || include_metrics.any? { |regexp| metric.match(regexp) }
|
@@ -160,7 +159,8 @@ class LogStash::Outputs::Graphite < LogStash::Outputs::Base
|
|
160
159
|
def messages_from_event_metrics(event, metrics)
|
161
160
|
timestamp = event_timestamp(event)
|
162
161
|
metrics.flat_map do |metric, value|
|
163
|
-
@logger.debug("processing", :metric => metric, :value => value)
|
162
|
+
@logger.debug? && @logger.debug("processing", :metric => metric, :value => value)
|
163
|
+
|
164
164
|
metric = event.sprintf(metric)
|
165
165
|
next unless @include_metrics.any? {|regexp| metric.match(regexp)}
|
166
166
|
next if @exclude_metrics.any? {|regexp| metric.match(regexp)}
|
@@ -175,7 +175,7 @@ class LogStash::Outputs::Graphite < LogStash::Outputs::Base
|
|
175
175
|
|
176
176
|
def metrics_lines_for_event(event, metric, value, timestamp)
|
177
177
|
if event[metric].is_a?(Hash)
|
178
|
-
dotify(event[metric], metric).map do |k,v|
|
178
|
+
dotify(event[metric], metric).map do |k, v|
|
179
179
|
metrics_line(event, k, v, timestamp)
|
180
180
|
end
|
181
181
|
else
|
@@ -190,9 +190,9 @@ class LogStash::Outputs::Graphite < LogStash::Outputs::Base
|
|
190
190
|
# Take a nested ruby hash of the form {:a => {:b => 2}, c: => 3} and
|
191
191
|
# turn it into a hash of the form
|
192
192
|
# { "a.b" => 2, "c" => 3}
|
193
|
-
def dotify(hash,prefix=nil)
|
194
|
-
hash.reduce({}) do |acc,kv|
|
195
|
-
k,v = kv
|
193
|
+
def dotify(hash, prefix = nil)
|
194
|
+
hash.reduce({}) do |acc, kv|
|
195
|
+
k, v = kv
|
196
196
|
pk = prefix ? "#{prefix}#{@nested_object_separator}#{k}" : k.to_s
|
197
197
|
if v.is_a?(Hash)
|
198
198
|
acc.merge!(dotify(v, pk))
|
@@ -205,5 +205,4 @@ class LogStash::Outputs::Graphite < LogStash::Outputs::Base
|
|
205
205
|
acc
|
206
206
|
end
|
207
207
|
end
|
208
|
-
|
209
|
-
end # class LogStash::Outputs::Graphite
|
208
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-output-graphite'
|
4
|
-
s.version = '2.0.
|
4
|
+
s.version = '2.0.3'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "This output allows you to pull metrics from your logs and ship them to Graphite"
|
7
7
|
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
metadata
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-graphite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
|
14
|
+
name: logstash-core
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
17
|
- - '>='
|
17
18
|
- !ruby/object:Gem::Version
|
@@ -19,10 +20,7 @@ dependencies:
|
|
19
20
|
- - <
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: 3.0.0
|
22
|
-
|
23
|
-
prerelease: false
|
24
|
-
type: :runtime
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
26
24
|
requirements:
|
27
25
|
- - '>='
|
28
26
|
- !ruby/object:Gem::Version
|
@@ -30,62 +28,64 @@ dependencies:
|
|
30
28
|
- - <
|
31
29
|
- !ruby/object:Gem::Version
|
32
30
|
version: 3.0.0
|
31
|
+
prerelease: false
|
32
|
+
type: :runtime
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
+
name: logstash-devutils
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
34
40
|
requirement: !ruby/object:Gem::Requirement
|
35
41
|
requirements:
|
36
42
|
- - '>='
|
37
43
|
- !ruby/object:Gem::Version
|
38
44
|
version: '0'
|
39
|
-
name: logstash-devutils
|
40
45
|
prerelease: false
|
41
46
|
type: :development
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: logstash-input-generator
|
42
49
|
version_requirements: !ruby/object:Gem::Requirement
|
43
50
|
requirements:
|
44
51
|
- - '>='
|
45
52
|
- !ruby/object:Gem::Version
|
46
53
|
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
54
|
requirement: !ruby/object:Gem::Requirement
|
49
55
|
requirements:
|
50
56
|
- - '>='
|
51
57
|
- !ruby/object:Gem::Version
|
52
58
|
version: '0'
|
53
|
-
name: logstash-input-generator
|
54
59
|
prerelease: false
|
55
60
|
type: :development
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: logstash-filter-kv
|
56
63
|
version_requirements: !ruby/object:Gem::Requirement
|
57
64
|
requirements:
|
58
65
|
- - '>='
|
59
66
|
- !ruby/object:Gem::Version
|
60
67
|
version: '0'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
68
|
requirement: !ruby/object:Gem::Requirement
|
63
69
|
requirements:
|
64
70
|
- - '>='
|
65
71
|
- !ruby/object:Gem::Version
|
66
72
|
version: '0'
|
67
|
-
name: logstash-filter-kv
|
68
73
|
prerelease: false
|
69
74
|
type: :development
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: logstash-filter-ruby
|
70
77
|
version_requirements: !ruby/object:Gem::Requirement
|
71
78
|
requirements:
|
72
79
|
- - '>='
|
73
80
|
- !ruby/object:Gem::Version
|
74
81
|
version: '0'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
82
|
requirement: !ruby/object:Gem::Requirement
|
77
83
|
requirements:
|
78
84
|
- - '>='
|
79
85
|
- !ruby/object:Gem::Version
|
80
86
|
version: '0'
|
81
|
-
name: logstash-filter-ruby
|
82
87
|
prerelease: false
|
83
88
|
type: :development
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - '>='
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '0'
|
89
89
|
description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
|
90
90
|
email: info@elastic.co
|
91
91
|
executables: []
|