logstash-input-graphite 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -3
- data/lib/logstash/inputs/graphite.rb +2 -0
- data/logstash-input-graphite.gemspec +1 -1
- data/spec/inputs/graphite_spec.rb +75 -0
- data/spec/spec_helper.rb +22 -0
- metadata +21 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f5a55f6d8be2888ade12a770059967edc2775d7
|
4
|
+
data.tar.gz: dc31a79474dfa2772cdf890fb1f5b9ffdfae1730
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a78ab75b268e6522ee48a5560ced4ee56077498772c2226f69adb4540283af8a014fca6971d10718bbe681c828b6b12362ca78a9d457a66b632bd2655ce2cbf
|
7
|
+
data.tar.gz: 21b4e79616d9531da9cee6dad53ea654e21b5b78054cebd022754b7caf024ec72468ca853d1f0844761530dfa2eb3c746a52a6057d3d1b0a853479fc77105747
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
## 2.0.2
|
2
|
+
- added comments and basic specs
|
1
3
|
## 2.0.0
|
2
|
-
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
4
|
+
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
3
5
|
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
4
|
-
- Dependency on logstash-core update to 2.0
|
5
|
-
|
6
|
+
- Dependency on logstash-core update to 2.0
|
@@ -21,6 +21,8 @@ class LogStash::Inputs::Graphite < LogStash::Inputs::Tcp
|
|
21
21
|
public
|
22
22
|
def run(output_queue)
|
23
23
|
@queue = output_queue
|
24
|
+
# pass self as output_queue to super Tcp#run - this is a hack so that the << calls in
|
25
|
+
# Tcp will actually call the << method defined below. This is twisted :P
|
24
26
|
super(self)
|
25
27
|
end
|
26
28
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-graphite'
|
4
|
-
s.version = '2.0.
|
4
|
+
s.version = '2.0.2'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Receive graphite metrics"
|
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"
|
@@ -1 +1,76 @@
|
|
1
1
|
require "logstash/devutils/rspec/spec_helper"
|
2
|
+
require "logstash/inputs/graphite"
|
3
|
+
require "logstash/timestamp"
|
4
|
+
require "time"
|
5
|
+
require_relative "../spec_helper"
|
6
|
+
|
7
|
+
describe LogStash::Inputs::Graphite do
|
8
|
+
|
9
|
+
before do
|
10
|
+
srand(RSpec.configuration.seed)
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:host) { "127.0.0.1" }
|
14
|
+
let(:port) { rand(1024..65535) }
|
15
|
+
let(:queue) { [] }
|
16
|
+
let(:client) { Stud::try(5.times) { TCPSocket.new(host, port) } }
|
17
|
+
let!(:helper) { TcpHelpers.new }
|
18
|
+
|
19
|
+
subject { LogStash::Inputs::Graphite.new("host" => host, "port" => port) }
|
20
|
+
|
21
|
+
after :each do
|
22
|
+
subject.close rescue nil
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "register" do
|
26
|
+
it "should register without errors" do
|
27
|
+
expect { subject.register }.to_not raise_error
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "receive" do
|
32
|
+
|
33
|
+
before(:each) do
|
34
|
+
subject.register
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should parse a graphite message" do
|
38
|
+
result = helper.pipelineless_input(subject, 1) do
|
39
|
+
client.write "a.b.c 10 N\n"
|
40
|
+
end
|
41
|
+
expect(result.size).to eq(1)
|
42
|
+
expect(result.first.to_hash).to include({"a.b.c" => 10})
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should parse a graphite message with floats" do
|
46
|
+
result = helper.pipelineless_input(subject, 1) do
|
47
|
+
client.write "a.b.c 10.2 N\n"
|
48
|
+
end
|
49
|
+
expect(result.size).to eq(1)
|
50
|
+
expect(result.first.to_hash).to include({"a.b.c" => 10.2})
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should support using N as current timestamp" do
|
54
|
+
time = LogStash::Timestamp.new(Time.now)
|
55
|
+
expect(Time).to receive(:now) { time }
|
56
|
+
result = helper.pipelineless_input(subject, 1) do
|
57
|
+
client.write "a.b.c 10 N\n"
|
58
|
+
end
|
59
|
+
expect(result.size).to eq(1)
|
60
|
+
expect(result.first["@timestamp"]).to eq(time)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should support using N as current timestamp" do
|
64
|
+
time = Time.at(Time.now.to_i) # truncate at the second
|
65
|
+
result = helper.pipelineless_input(subject, 1) do
|
66
|
+
client.write "a.b.c 10 #{time.to_i}\n"
|
67
|
+
end
|
68
|
+
expect(result.size).to eq(1)
|
69
|
+
expect(result.first["@timestamp"]).to eq(LogStash::Timestamp.new(time))
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it_behaves_like "an interruptible input plugin" do
|
74
|
+
let(:config) { { "port" => port } }
|
75
|
+
end
|
76
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/devutils/rspec/spec_helper"
|
3
|
+
|
4
|
+
# this has been taken from the udp input, it should be DRYed
|
5
|
+
|
6
|
+
class TcpHelpers
|
7
|
+
|
8
|
+
def pipelineless_input(plugin, size, &block)
|
9
|
+
queue = Queue.new
|
10
|
+
input_thread = Thread.new do
|
11
|
+
plugin.run(queue)
|
12
|
+
end
|
13
|
+
block.call
|
14
|
+
sleep 0.1 while queue.size != size
|
15
|
+
result = size.times.inject([]) do |acc|
|
16
|
+
acc << queue.pop
|
17
|
+
end
|
18
|
+
plugin.do_stop
|
19
|
+
input_thread.join
|
20
|
+
result
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-graphite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
@@ -11,7 +11,8 @@ cert_chain: []
|
|
11
11
|
date: 2015-10-08 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,49 +28,52 @@ 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-input-tcp
|
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-input-tcp
|
40
45
|
prerelease: false
|
41
46
|
type: :runtime
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: logstash-devutils
|
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-devutils
|
54
59
|
prerelease: false
|
55
60
|
type: :development
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - '>='
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
61
61
|
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
|
62
62
|
email: info@elastic.co
|
63
63
|
executables: []
|
64
64
|
extensions: []
|
65
65
|
extra_rdoc_files: []
|
66
66
|
files:
|
67
|
+
- lib/logstash/inputs/graphite.rb
|
68
|
+
- spec/spec_helper.rb
|
69
|
+
- spec/inputs/graphite_spec.rb
|
70
|
+
- logstash-input-graphite.gemspec
|
67
71
|
- CHANGELOG.md
|
72
|
+
- README.md
|
68
73
|
- CONTRIBUTORS
|
69
74
|
- Gemfile
|
70
75
|
- LICENSE
|
71
76
|
- NOTICE.TXT
|
72
|
-
- README.md
|
73
|
-
- lib/logstash/inputs/graphite.rb
|
74
|
-
- logstash-input-graphite.gemspec
|
75
|
-
- spec/inputs/graphite_spec.rb
|
76
77
|
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
77
78
|
licenses:
|
78
79
|
- Apache License (2.0)
|
@@ -95,9 +96,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
96
|
version: '0'
|
96
97
|
requirements: []
|
97
98
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.1.9
|
99
100
|
signing_key:
|
100
101
|
specification_version: 4
|
101
102
|
summary: Receive graphite metrics
|
102
103
|
test_files:
|
104
|
+
- spec/spec_helper.rb
|
103
105
|
- spec/inputs/graphite_spec.rb
|