fluent-plugin-influxdb_metrics 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +4 -1
- data/VERSION +1 -1
- data/fluent-plugin-influxdb_metrics.gemspec +1 -0
- data/lib/fluent/plugin/out_influxdb_metrics.rb +13 -18
- data/test/plugin/test_out_influxdb_metrics.rb +1 -1
- metadata +19 -3
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent-plugin-influxdb_metrics (0.0.
|
4
|
+
fluent-plugin-influxdb_metrics (0.0.3)
|
5
5
|
fluentd
|
6
|
+
influxdb
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
@@ -19,6 +20,8 @@ GEM
|
|
19
20
|
sigdump (~> 0.2.2)
|
20
21
|
yajl-ruby (~> 1.0)
|
21
22
|
http_parser.rb (0.6.0)
|
23
|
+
influxdb (0.1.7)
|
24
|
+
json
|
22
25
|
json (1.8.1)
|
23
26
|
msgpack (0.5.8)
|
24
27
|
rake (10.3.2)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'date'
|
3
|
-
require '
|
3
|
+
require 'influxdb'
|
4
4
|
|
5
5
|
class Fluent::InfluxdbMetricsOutput < Fluent::BufferedOutput
|
6
6
|
Fluent::Plugin.register_output('influxdb_metrics', self)
|
@@ -38,6 +38,14 @@ class Fluent::InfluxdbMetricsOutput < Fluent::BufferedOutput
|
|
38
38
|
super
|
39
39
|
end
|
40
40
|
|
41
|
+
def influx_client
|
42
|
+
@influxdb ||= InfluxDB::Client.new(@dbname, host: @host,
|
43
|
+
port: @port,
|
44
|
+
username: @user,
|
45
|
+
password: @password)
|
46
|
+
@influxdb
|
47
|
+
end
|
48
|
+
|
41
49
|
def write(chunk)
|
42
50
|
bulk = []
|
43
51
|
|
@@ -46,16 +54,11 @@ class Fluent::InfluxdbMetricsOutput < Fluent::BufferedOutput
|
|
46
54
|
bulk << formatted_record if formatted_record
|
47
55
|
end
|
48
56
|
|
49
|
-
|
50
|
-
resp, _ = http.post("/db/#{@dbname}/series?u=#{@user}&p=#{@password}&time_precision=s",
|
51
|
-
Yajl::Encoder.encode(bulk) + "\n",
|
52
|
-
'Content-Type' => 'text/json')
|
53
|
-
resp.value
|
57
|
+
influx_client.write_point(@table, bulk, false, 's')
|
54
58
|
end
|
55
59
|
|
56
60
|
def format_record(tag, time, record)
|
57
|
-
|
58
|
-
points = [time]
|
61
|
+
metric = {time: time}
|
59
62
|
|
60
63
|
filter_keys.each do |field|
|
61
64
|
path = field.split('.')
|
@@ -65,19 +68,11 @@ class Fluent::InfluxdbMetricsOutput < Fluent::BufferedOutput
|
|
65
68
|
end
|
66
69
|
|
67
70
|
if rec_pos
|
68
|
-
|
69
|
-
points << rec_pos
|
71
|
+
metric[field] = rec_pos
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
73
|
-
if
|
74
|
-
return {
|
75
|
-
name: @table,
|
76
|
-
columns: cols,
|
77
|
-
points: [points]
|
78
|
-
}
|
79
|
-
end
|
80
|
-
|
75
|
+
return metric if metric.keys.length > 1
|
81
76
|
nil
|
82
77
|
end
|
83
78
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-influxdb_metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: influxdb
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: rake
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
107
|
version: '0'
|
92
108
|
segments:
|
93
109
|
- 0
|
94
|
-
hash:
|
110
|
+
hash: 3109599464123392193
|
95
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
112
|
none: false
|
97
113
|
requirements:
|
@@ -100,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
116
|
version: '0'
|
101
117
|
segments:
|
102
118
|
- 0
|
103
|
-
hash:
|
119
|
+
hash: 3109599464123392193
|
104
120
|
requirements: []
|
105
121
|
rubyforge_project:
|
106
122
|
rubygems_version: 1.8.23
|