logstash-output-influxdb 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/lib/logstash/outputs/influxdb.rb +17 -13
- data/logstash-output-influxdb.gemspec +6 -4
- data/spec/outputs/influxdb_spec.rb +42 -0
- metadata +34 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6f61107587eab684af48a9435abdf68f73bfca5
|
4
|
+
data.tar.gz: 06bad73341f74d379316ec90654d6d5b78e7349c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52530dbc46948873507fb1525826e3e805d641ef355c84ae8116e880479f908376c476e7bbbd60de31556f2fe0c8b6e7ddb17ac6bbab273eab663c98785812e5
|
7
|
+
data.tar.gz: c6d1e37d7948f87179827a4d87ead5294ba6f964fa0291ba05c5a931acf825390e040b0c7a7d758fb05c3b239d7843152efbcae708f4d719117bb17bc12deb24
|
data/LICENSE
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "logstash/namespace"
|
3
3
|
require "logstash/outputs/base"
|
4
|
+
require "logstash/json"
|
4
5
|
require "stud/buffer"
|
5
6
|
|
6
7
|
# This output lets you output Metrics to InfluxDB
|
@@ -93,14 +94,14 @@ class LogStash::Outputs::InfluxDB < LogStash::Outputs::Base
|
|
93
94
|
@query_params = "u=#{@user}&p=#{@password.value}&time_precision=#{@time_precision}"
|
94
95
|
@base_url = "http://#{@host}:#{@port}/db/#{@db}/series"
|
95
96
|
@url = "#{@base_url}?#{@query_params}"
|
96
|
-
|
97
|
+
|
97
98
|
buffer_initialize(
|
98
99
|
:max_items => @flush_size,
|
99
100
|
:max_interval => @idle_flush_time,
|
100
101
|
:logger => @logger
|
101
102
|
)
|
102
103
|
end # def register
|
103
|
-
|
104
|
+
|
104
105
|
public
|
105
106
|
def receive(event)
|
106
107
|
return unless output?(event)
|
@@ -125,21 +126,26 @@ class LogStash::Outputs::InfluxDB < LogStash::Outputs::Base
|
|
125
126
|
# ]
|
126
127
|
event_hash = {}
|
127
128
|
event_hash['name'] = event.sprintf(@series)
|
129
|
+
|
128
130
|
sprintf_points = Hash[@data_points.map {|k,v| [event.sprintf(k), event.sprintf(v)]}]
|
129
131
|
if sprintf_points.has_key?('time')
|
130
|
-
|
132
|
+
unless @allow_time_override
|
133
|
+
logger.error("Cannot override value of time without 'allow_time_override'. Using event timestamp")
|
134
|
+
sprintf_points['time'] = event.timestamp.to_i
|
135
|
+
end
|
131
136
|
else
|
132
137
|
sprintf_points['time'] = event.timestamp.to_i
|
133
138
|
end
|
139
|
+
|
134
140
|
@coerce_values.each do |column, value_type|
|
135
141
|
if sprintf_points.has_key?(column)
|
136
142
|
begin
|
137
143
|
case value_type
|
138
144
|
when "integer"
|
139
|
-
@logger.debug("Converting column #{column} to type #{value_type}: Current value: #{sprintf_points[column]}")
|
145
|
+
@logger.debug? and @logger.debug("Converting column #{column} to type #{value_type}: Current value: #{sprintf_points[column]}")
|
140
146
|
sprintf_points[column] = sprintf_points[column].to_i
|
141
147
|
when "float"
|
142
|
-
@logger.debug("Converting column #{column} to type #{value_type}: Current value: #{sprintf_points[column]}")
|
148
|
+
@logger.debug? and @logger.debug("Converting column #{column} to type #{value_type}: Current value: #{sprintf_points[column]}")
|
143
149
|
sprintf_points[column] = sprintf_points[column].to_f
|
144
150
|
else
|
145
151
|
@logger.error("Don't know how to convert to #{value_type}")
|
@@ -149,17 +155,15 @@ class LogStash::Outputs::InfluxDB < LogStash::Outputs::Base
|
|
149
155
|
end
|
150
156
|
end
|
151
157
|
end
|
158
|
+
|
152
159
|
event_hash['columns'] = sprintf_points.keys
|
153
160
|
event_hash['points'] = []
|
154
161
|
event_hash['points'] << sprintf_points.values
|
162
|
+
|
155
163
|
buffer_receive(event_hash)
|
156
164
|
end # def receive
|
157
165
|
|
158
|
-
|
159
|
-
def flush(events, teardown=false)
|
160
|
-
# Avoid creating a new string for newline every time
|
161
|
-
newline = "\n".freeze
|
162
|
-
|
166
|
+
def flush(events, teardown = false)
|
163
167
|
# seen_series stores a list of series and associated columns
|
164
168
|
# we've seen for each event
|
165
169
|
# so that we can attempt to batch up points for a given series.
|
@@ -181,13 +185,13 @@ class LogStash::Outputs::InfluxDB < LogStash::Outputs::Base
|
|
181
185
|
seen_series[ev['name']] = ev['columns']
|
182
186
|
event_collection << ev
|
183
187
|
end
|
184
|
-
rescue
|
185
|
-
@logger.
|
188
|
+
rescue => e
|
189
|
+
@logger.warn("Error adding event to collection", :exception => e)
|
186
190
|
next
|
187
191
|
end
|
188
192
|
end
|
189
193
|
|
190
|
-
post(event_collection
|
194
|
+
post(LogStash::Json.dump(event_collection))
|
191
195
|
end # def receive_bulk
|
192
196
|
|
193
197
|
def post(body)
|
@@ -1,13 +1,13 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-output-influxdb'
|
4
|
-
s.version = '0.1.
|
4
|
+
s.version = '0.1.4'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "This output lets you output Metrics to InfluxDB"
|
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"
|
8
|
-
s.authors = ["
|
9
|
-
s.email = 'info@
|
10
|
-
s.homepage = "http://www.
|
8
|
+
s.authors = ["Elastic"]
|
9
|
+
s.email = 'info@elastic.co'
|
10
|
+
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
|
11
11
|
s.require_paths = ["lib"]
|
12
12
|
|
13
13
|
# Files
|
@@ -26,5 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_runtime_dependency 'ftw', ['~> 0.0.40']
|
27
27
|
|
28
28
|
s.add_development_dependency 'logstash-devutils'
|
29
|
+
s.add_development_dependency 'logstash-input-generator'
|
30
|
+
s.add_development_dependency 'logstash-filter-kv'
|
29
31
|
end
|
30
32
|
|
@@ -1 +1,43 @@
|
|
1
1
|
require "logstash/devutils/rspec/spec_helper"
|
2
|
+
require "logstash/outputs/influxdb"
|
3
|
+
|
4
|
+
describe LogStash::Outputs::InfluxDB do
|
5
|
+
|
6
|
+
let(:pipeline) { LogStash::Pipeline.new(config) }
|
7
|
+
|
8
|
+
context "complete pipeline run with 2 events" do
|
9
|
+
|
10
|
+
let(:config) do <<-CONFIG
|
11
|
+
input {
|
12
|
+
generator {
|
13
|
+
message => "foo=1 bar=2 time=3"
|
14
|
+
count => 2
|
15
|
+
type => "generator"
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
filter {
|
20
|
+
kv { }
|
21
|
+
}
|
22
|
+
|
23
|
+
output {
|
24
|
+
influxdb {
|
25
|
+
host => "localhost"
|
26
|
+
user => "someuser"
|
27
|
+
password => "somepwd"
|
28
|
+
allow_time_override => true
|
29
|
+
data_points => {"foo" => "%{foo}" "bar" => "%{bar}" "time" => "%{time}"}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
CONFIG
|
33
|
+
end
|
34
|
+
|
35
|
+
let(:json_result) { "[{\"name\":\"logstash\",\"columns\":[\"foo\",\"bar\",\"time\"],\"points\":[[\"1\",\"2\",\"3\"],[\"1\",\"2\",\"3\"]]}]" }
|
36
|
+
|
37
|
+
it "should receive 2 events, flush and call post with 2 items json array" do
|
38
|
+
expect_any_instance_of(LogStash::Outputs::InfluxDB).to receive(:post).with(json_result)
|
39
|
+
pipeline.run
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-influxdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
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-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,8 +72,36 @@ dependencies:
|
|
72
72
|
- - '>='
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
name: logstash-input-generator
|
82
|
+
prerelease: false
|
83
|
+
type: :development
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
name: logstash-filter-kv
|
96
|
+
prerelease: false
|
97
|
+
type: :development
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
75
103
|
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
|
76
|
-
email: info@
|
104
|
+
email: info@elastic.co
|
77
105
|
executables: []
|
78
106
|
extensions: []
|
79
107
|
extra_rdoc_files: []
|
@@ -87,7 +115,7 @@ files:
|
|
87
115
|
- lib/logstash/outputs/influxdb.rb
|
88
116
|
- logstash-output-influxdb.gemspec
|
89
117
|
- spec/outputs/influxdb_spec.rb
|
90
|
-
homepage: http://www.
|
118
|
+
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
91
119
|
licenses:
|
92
120
|
- Apache License (2.0)
|
93
121
|
metadata:
|
@@ -109,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
137
|
version: '0'
|
110
138
|
requirements: []
|
111
139
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
140
|
+
rubygems_version: 2.1.9
|
113
141
|
signing_key:
|
114
142
|
specification_version: 4
|
115
143
|
summary: This output lets you output Metrics to InfluxDB
|