fluent-plugin-influxdb 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e0bf2fdba5bf409df21056b7535b48aa42fe647a
4
+ data.tar.gz: a9f986c7cb0d934eaf0719986f7522137596c575
5
+ SHA512:
6
+ metadata.gz: d0b1f437ae5f239c75cd4e538fad64309ffc6a001a59bd4bd6342041256e8ead963f06b0607c496ce929b7c66346f564cc2c60cd027b0f3ea7d09b15ccd239d7
7
+ data.tar.gz: 973227cf17b6a02d5188cbfd0110cfc3605added81f9c5d6c5a458798bd6a9ebd86bfc838af5e70672b478d03fb1fe7f3dcd010339ec906d5eed7f6ddbdc4648
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *.rbc
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-influxdb.gemspec
4
+ gemspec
5
+
6
+ gem 'coveralls', require: false
data/History.md ADDED
@@ -0,0 +1,7 @@
1
+ Changelog
2
+ =========
3
+
4
+ 0.1.0
5
+ =====
6
+
7
+ - Initial gem release.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Fang.Li <surivlee@gmail.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # Fluent::Plugin::InfluxDB
2
+
3
+ fluent-plugin-influxdb is a buffered output plugin for fluentd and influxDB.
4
+
5
+ If you are using fluentd as a collector and want to organize your time-series data in influxDB, this is your right choice!
6
+
7
+ ## Installation
8
+
9
+ $ gem install fluent-plugin-influxdb
10
+
11
+ ## Usage
12
+
13
+ Just like other regular output plugins, Use type `influxdb` in your fluentd configuration under `match` scope:
14
+
15
+ `type` `influxdb`
16
+
17
+ --------------
18
+
19
+ **Options:**
20
+
21
+ `host`: The IP or domain of influxDB, default to "localhost"
22
+
23
+ `port`: The HTTP port of influxDB, default to 8086
24
+
25
+ `dbname`: The database name of influxDB, default to "fluentd". you should create the database and grant permissions first
26
+
27
+ `user`: The DB user of influxDB, should be created manually, default to "root"
28
+
29
+ `password`: The password of the user, default to "root"
30
+
31
+ `value_field`: The original data field in fluentd, default to "_value".
32
+
33
+ If you have a fluentd time-series schema like this:
34
+ my.metric.name 1386000000 {"k1":"v1","k2":"v2","count":2.3}
35
+ And apparently the field "count" is the value field, you should set it to "count"
36
+
37
+ `time_precision`: The time precision of timestamp. default to "s". should specify either second (s), millisecond (m), or microsecond (u)
38
+
39
+
40
+
41
+ ## Configuration Example
42
+
43
+
44
+ ```
45
+ <match mylog.*>
46
+ type influxdb
47
+ host localhost
48
+ port 8086
49
+ dbname test
50
+ user testuser
51
+ password mypwd
52
+ value_field count
53
+ time_precision s
54
+ </match>
55
+ ```
56
+
57
+ ## Cache and multiprocess
58
+
59
+
60
+ fluentd-plugin-influxdb is a buffered output plugin. So additional buffer configuration would be (with default values):
61
+
62
+ ```
63
+ buffer_type memory
64
+ flush_interval 60
65
+ retry_limit 17
66
+ retry_wait 1.0
67
+ num_threads 1
68
+ ```
69
+
70
+ ---
71
+
72
+ Also please consider using [fluent-plugin-multiprocess](https://github.com/frsyuki/fluent-plugin-multiprocess) to fork multiple threads for your metrics:
73
+
74
+ ## Contributing
75
+
76
+
77
+ 1. Fork it
78
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
79
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
80
+ 4. Push to the branch (`git push origin my-new-feature`)
81
+ 5. Create new Pull Request
82
+
83
+
84
+ ## Licence
85
+
86
+
87
+ This package was distributed under MIT licence, see LICENCE file for details.
88
+
89
+ This plugin was written by Fang.Li and was inspired by [Uken's](https://github.com/uken/fluent-plugin-elasticsearch) elasticsearch plugin.
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |test|
5
+ test.libs << 'lib' << 'test'
6
+ test.pattern = 'test/**/test_*.rb'
7
+ test.verbose = true
8
+ end
9
+
10
+ task :default => :test
11
+
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "fluent-plugin-influxdb"
6
+ s.version = '0.1.0'
7
+ s.authors = ["FangLi"]
8
+ s.email = ["surivlee@gmail.com"]
9
+ s.description = %q{InfluxDB output plugin for Fluentd}
10
+ s.summary = %q{A buffered output plugin for fluentd and influxDB}
11
+ s.homepage = "https://github.com/fangli/fluent-plugin-influxdb"
12
+ s.license = 'MIT'
13
+
14
+ s.files = `git ls-files`.split($/)
15
+ s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_runtime_dependency "fluentd"
20
+
21
+ s.add_development_dependency "rake"
22
+ s.add_development_dependency "webmock"
23
+ end
@@ -0,0 +1,57 @@
1
+ # encoding: UTF-8
2
+ require 'date'
3
+ require 'net/http'
4
+
5
+ class Fluent::InfluxdbOutput < Fluent::BufferedOutput
6
+ Fluent::Plugin.register_output('influxdb', self)
7
+
8
+ config_param :host, :string, :default => 'localhost'
9
+ config_param :port, :integer, :default => 8086
10
+ config_param :dbname, :string, :default => 'fluentd'
11
+ config_param :user, :string, :default => 'root'
12
+ config_param :password, :string, :default => 'root'
13
+ config_param :value_field, :string, :default => '_value'
14
+ config_param :time_precision, :string, :default => 's'
15
+
16
+
17
+ def initialize
18
+ super
19
+ end
20
+
21
+ def configure(conf)
22
+ super
23
+ end
24
+
25
+ def start
26
+ super
27
+ end
28
+
29
+ def format(tag, time, record)
30
+ [tag, time, record].to_msgpack
31
+ end
32
+
33
+ def shutdown
34
+ super
35
+ end
36
+
37
+ def write(chunk)
38
+ bulk = []
39
+
40
+ chunk.msgpack_each do |tag, time, record|
41
+
42
+ value = record[@value_field]
43
+ record.delete(@value_field)
44
+
45
+ bulk << {
46
+ 'name' => tag,
47
+ 'columns' => ['time', 'value'].concat(record.keys),
48
+ 'points' => [[time, value].concat(record.values)],
49
+ }
50
+ end
51
+
52
+ http = Net::HTTP.new(@host, @port.to_i)
53
+ request = Net::HTTP::Post.new("/db/#{@dbname}/series?u=#{@user}&p=#{password}&time_precision=#{time_precision}", {'content-type' => 'application/json; charset=utf-8'})
54
+ request.body = Yajl::Encoder.encode(bulk)
55
+ http.request(request).value
56
+ end
57
+ end
data/test/helper.rb ADDED
@@ -0,0 +1 @@
1
+ require 'minitest/pride'
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-influxdb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - FangLi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluentd
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: webmock
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: InfluxDB output plugin for Fluentd
56
+ email:
57
+ - surivlee@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - History.md
65
+ - LICENSE
66
+ - README.md
67
+ - Rakefile
68
+ - fluent-plugin-influxdb.gemspec
69
+ - lib/fluent/plugin/out_influxdb.rb
70
+ - test/helper.rb
71
+ homepage: https://github.com/fangli/fluent-plugin-influxdb
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.0.3
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: A buffered output plugin for fluentd and influxDB
95
+ test_files:
96
+ - test/helper.rb