fluent-plugin-simple-logentries 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cfc43c1522f9777ae9209c1b056fb1925d3642be
4
+ data.tar.gz: 69f7482845701c7d8aec0942403d9f38165817e3
5
+ SHA512:
6
+ metadata.gz: df1a9f26b4473c788693483903043cfad2581dad703638e209ca5d1b5d0bc815f741c9eb72891435464af6a5a64172f5bcd87cd9e3315263c24456170a7ba6db
7
+ data.tar.gz: 68bdf4922f142259d1d041c3044655e6f9465c449f13f472b5aa50e085ffc44a2676eb30c807c6819861e0cb675aa60d9d6e692f5bf6176218414bc6ad72b128
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,22 @@
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-simple-logentries"
7
+ spec.version = "0.0.3"
8
+ spec.description = "Push fluent events to Logentries"
9
+ spec.authors = ["sowawa"]
10
+ spec.email = ["kesiuke.sogawa@gmail.com"]
11
+ spec.summary = "Logentries output plugin for Fluent event collector"
12
+ spec.homepage = "https://github.com/sowawa/fluent-plugin-simple-logentries"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.6"
21
+ spec.add_development_dependency 'rake', '~> 0'
22
+ end
@@ -0,0 +1,82 @@
1
+ require 'socket'
2
+ require 'json'
3
+ require 'openssl'
4
+
5
+ class Fluent::SimpleLogentriesOutput < Fluent::BufferedOutput
6
+ class ConnectionFailure < StandardError; end
7
+ Fluent::Plugin.register_output('simple-logentries', self)
8
+
9
+ config_param :use_ssl, :bool, :default => true
10
+ config_param :port, :integer, :default => 20000
11
+ config_param :protocol, :string, :default => 'tcp'
12
+ config_param :max_retries, :integer, :default => 3
13
+ config_param :append_tag, :bool, :default => true
14
+ config_param :token, :string
15
+ SSL_HOST = "api.logentries.com"
16
+ NO_SSL_HOST = "data.logentries.com"
17
+
18
+ def configure(conf)
19
+ super
20
+ @last_edit = Time.at(0)
21
+ end
22
+
23
+ def start
24
+ super
25
+ end
26
+
27
+ def shutdown
28
+ super
29
+ end
30
+
31
+ def client
32
+ @_socket ||= if @use_ssl
33
+ context = OpenSSL::SSL::SSLContext.new
34
+ socket = TCPSocket.new SSL_HOST, @port
35
+ ssl_client = OpenSSL::SSL::SSLSocket.new socket, context
36
+
37
+ ssl_client.connect
38
+ else
39
+ if @protocol == 'tcp'
40
+ TCPSocket.new NO_SSL_HOST, @port
41
+ else
42
+ udp_client = UDPSocket.new
43
+ udp_client.connect NO_SSL_HOST, @port
44
+
45
+ udp_client
46
+ end
47
+ end
48
+ end
49
+
50
+ def format(tag, time, record)
51
+ return [tag, record].to_msgpack
52
+ end
53
+
54
+ def write(chunk)
55
+ chunk.msgpack_each do |tag, record|
56
+ if record.is_a? Hash
57
+ send_logentries(@token,
58
+ JSON.generate(
59
+ @append_tag ? record.merge({tag: tag}) : record))
60
+ end
61
+ end
62
+ end
63
+
64
+ def send_logentries(token, data)
65
+ retries = 0
66
+ begin
67
+ client.write("#{token} #{data} \n")
68
+ rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT => e
69
+ if retries < @max_retries
70
+ retries += 1
71
+ @_socket = nil
72
+ log.warn "Could not push logs to Logentries, resetting connection and trying again. #{e.message}"
73
+ sleep 5**retries
74
+ retry
75
+ end
76
+ raise ConnectionFailure, "Could not push logs to Logentries after #{retries} retries. #{e.message}"
77
+ rescue Errno::EMSGSIZE
78
+ log.warn "Could not push logs to Logentries. #{e.message}"
79
+ end
80
+ end
81
+
82
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-simple-logentries
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - sowawa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-29 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.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
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
+ description: Push fluent events to Logentries
42
+ email:
43
+ - kesiuke.sogawa@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - Gemfile
49
+ - fluent-plugin-simple-logentries.gemspec
50
+ - lib/fluent/plugin/out_simple-logentries.rb
51
+ homepage: https://github.com/sowawa/fluent-plugin-simple-logentries
52
+ licenses:
53
+ - MIT
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.2.2
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: Logentries output plugin for Fluent event collector
75
+ test_files: []