fluent-plugin-logsene 0.0.1
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 +7 -0
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +11 -0
- data/fluent-plugin-logsene.gemspec +25 -0
- data/lib/fluent/plugin/out_logsene.rb +68 -0
- data/test/helper.rb +28 -0
- data/test/plugin/test_out_logsene.rb +56 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 927209293db40c4200d374a08458b530fb6e3ac2
|
4
|
+
data.tar.gz: 81d40812aad238bea89fe19b19f1e57b5bf197a3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a12ec36c013815f484252ca81613cd21ac07b8cabfa952be2eea0dab4ff1a50ac8f608aa56738e3b1fddf1e41c045189663afcc38cfd93ae0bd5360f09541b4a
|
7
|
+
data.tar.gz: 6b0c5bb77cd4734dfdcde32f358ce7ea4df1c20458c5bbc29657e0e8550ddb64376eb6a14a7bfa0c0285eb587b2cd9d9791a37116a6d04da905ea36bb6b8af7a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Sematext; 2013 memorycraft
|
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,34 @@
|
|
1
|
+
# Logsene Fluent Plugin
|
2
|
+
[Fluentd](http://fluentd.org) output plugin for [Logsene](http://sematext.com/logsene).
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
gem 'fluent-plugin-logsene'
|
8
|
+
|
9
|
+
And then execute:
|
10
|
+
|
11
|
+
$ bundle
|
12
|
+
|
13
|
+
Or install it yourself as:
|
14
|
+
|
15
|
+
$ gem install fluent-plugin-logsene
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
Simply replace the dummy application token in the `path` configuration setting with the one you can find on the `App Actions > App Settings` or the `Integration` page when you sign in on [https://apps.sematext.com](https://apps.sematext.com).
|
19
|
+
Of course, you should customize the match regex to include your logs of choice.
|
20
|
+
|
21
|
+
<match *.syslog.*>
|
22
|
+
type logsene
|
23
|
+
path /5233x41x-3xx5-8754-x354-xxx1x018ex33x
|
24
|
+
</match>
|
25
|
+
|
26
|
+
It's that simple!
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "fluent-plugin-logsene"
|
7
|
+
spec.version = "0.0.1"
|
8
|
+
spec.authors = ["Sematext"]
|
9
|
+
spec.email = ["info@sematext.com"]
|
10
|
+
spec.description = %q{fluent plugin for logsene}
|
11
|
+
spec.summary = %q{Logsene is a centralized log management solution from Sematext. The plugin is fluentd output plugin for Logsene}
|
12
|
+
spec.homepage = "https://github.com/mbonaci/fluent-plugin-logsene"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.rubyforge_project = "fluent-plugin-logsene"
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_runtime_dependency "fluentd"
|
25
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'net/http'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
class Fluent::LogseneOutput< Fluent::BufferedOutput
|
6
|
+
Fluent::Plugin.register_output('logsene', self)
|
7
|
+
|
8
|
+
config_param :host, :string, :default => 'logsene-receiver.sematext.com'
|
9
|
+
config_param :port, :integer, :default => 443
|
10
|
+
config_param :path, :string, :default => ''
|
11
|
+
config_param :format, :string, :default => 'json'
|
12
|
+
|
13
|
+
include Fluent::SetTagKeyMixin
|
14
|
+
config_set_default :include_tag_key, false
|
15
|
+
|
16
|
+
include Fluent::SetTimeKeyMixin
|
17
|
+
config_set_default :include_time_key, false
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def configure(conf)
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
def start
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
def format(tag, time, record)
|
32
|
+
[tag, time, record].to_msgpack
|
33
|
+
end
|
34
|
+
|
35
|
+
def shutdown
|
36
|
+
super
|
37
|
+
end
|
38
|
+
|
39
|
+
def write(chunk)
|
40
|
+
messages = []
|
41
|
+
|
42
|
+
case @format
|
43
|
+
when 'json'
|
44
|
+
chunk.msgpack_each do |tag, time, record|
|
45
|
+
if @include_tag_key
|
46
|
+
record.merge!(@tag_key => tag)
|
47
|
+
end
|
48
|
+
if @include_time_key
|
49
|
+
record.merge!(@time_key => @timef.format(time))
|
50
|
+
end
|
51
|
+
messages << record.to_json
|
52
|
+
end
|
53
|
+
when 'text'
|
54
|
+
chunk.msgpack_each do |tag, time, record|
|
55
|
+
messages << record['message']
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
http = Net::HTTP.new(@host, @port.to_i)
|
60
|
+
http.use_ssl = true
|
61
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
62
|
+
http.set_debug_output $stderr
|
63
|
+
|
64
|
+
request = Net::HTTP::Post.new(@path)
|
65
|
+
request.body = messages.join("\n")
|
66
|
+
http.request(request)
|
67
|
+
end
|
68
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
require 'fluent/test'
|
15
|
+
unless ENV.has_key?('VERBOSE')
|
16
|
+
nulllogger = Object.new
|
17
|
+
nulllogger.instance_eval {|obj|
|
18
|
+
def method_missing(method, *args)
|
19
|
+
# pass
|
20
|
+
end
|
21
|
+
}
|
22
|
+
$log = nulllogger
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'fluent/plugin/out_logsene'
|
26
|
+
|
27
|
+
class Test::Unit::TestCase
|
28
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class LogseneOutputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
end
|
7
|
+
|
8
|
+
CONFIG = %[
|
9
|
+
]
|
10
|
+
# CONFIG = %[
|
11
|
+
# path #{TMP_DIR}/out_file_test
|
12
|
+
# compress gz
|
13
|
+
# utc
|
14
|
+
# ]
|
15
|
+
|
16
|
+
def create_driver(conf = CONFIG, tag='test')
|
17
|
+
Fluent::Test::BufferedOutputTestDriver.new(Fluent::LogseneOutput, tag).configure(conf)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_configure
|
21
|
+
#### set configurations
|
22
|
+
# d = create_driver %[
|
23
|
+
# path test_path
|
24
|
+
# compress gz
|
25
|
+
# ]
|
26
|
+
#### check configurations
|
27
|
+
# assert_equal 'test_path', d.instance.path
|
28
|
+
# assert_equal :gz, d.instance.compress
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_format
|
32
|
+
d = create_driver
|
33
|
+
|
34
|
+
# time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
35
|
+
# d.emit({"a"=>1}, time)
|
36
|
+
# d.emit({"a"=>2}, time)
|
37
|
+
|
38
|
+
# d.expect_format %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n]
|
39
|
+
# d.expect_format %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n]
|
40
|
+
|
41
|
+
# d.run
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_write
|
45
|
+
d = create_driver
|
46
|
+
|
47
|
+
# time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
48
|
+
# d.emit({"a"=>1}, time)
|
49
|
+
# d.emit({"a"=>2}, time)
|
50
|
+
|
51
|
+
# ### FileOutput#write returns path
|
52
|
+
# path = d.run
|
53
|
+
# expect_path = "#{TMP_DIR}/out_file_test._0.log.gz"
|
54
|
+
# assert_equal expect_path, path
|
55
|
+
end
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-logsene
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sematext
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
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: fluentd
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: fluent plugin for logsene
|
56
|
+
email:
|
57
|
+
- info@sematext.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- fluent-plugin-logsene.gemspec
|
68
|
+
- lib/fluent/plugin/out_logsene.rb
|
69
|
+
- test/helper.rb
|
70
|
+
- test/plugin/test_out_logsene.rb
|
71
|
+
homepage: https://github.com/mbonaci/fluent-plugin-logsene
|
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: fluent-plugin-logsene
|
91
|
+
rubygems_version: 2.4.8
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Logsene is a centralized log management solution from Sematext. The plugin
|
95
|
+
is fluentd output plugin for Logsene
|
96
|
+
test_files:
|
97
|
+
- test/helper.rb
|
98
|
+
- test/plugin/test_out_logsene.rb
|