fluent-plugin-logmatic 0.7 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4a8ae2452e547650e5139666b2e11e16a849552
4
- data.tar.gz: 952cf838c0ebd948448569299680347196791456
3
+ metadata.gz: 832872f431650bee4cecd717357c628e242b35a2
4
+ data.tar.gz: f62d2ff84f5bc7d3e7626255b8fb7a783a67d3c9
5
5
  SHA512:
6
- metadata.gz: 7cc21ad106c3f519700cbc4e0b4b2434abe7ed124b2f3ea0bca8c63623499afab82f4288bdbf7cea43235fed946cadaf8f8d34c3ada4b7c5706618f3ee99b521
7
- data.tar.gz: 228734eba5ef3240140ac6903d4c18a3764fbefbd3a96f394e2185a399267e64c80e088225fe7b554f6e47d16162b32c722844c737268ebab28aadd862bcb258
6
+ metadata.gz: ce4c3d94d809bcb6b8dfb56da7b1e56a082bc8a0342a87145595141b190222f8d4e4e0bd34da38d955c303e779662de2acb1fa903cd8f384c287a9fccf5d0597
7
+ data.tar.gz: 9e916639430b84d386724403c7dada85fd1a5b7f72e5fa2a57d1fb9527529e8a6876920ab2f80826011457aa3b4ecc7140d1db04c84ecb8e0154389a51767397
data/.gitignore CHANGED
@@ -34,3 +34,8 @@ build/
34
34
 
35
35
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
36
  .rvmrc
37
+
38
+ # Misc
39
+ foo/
40
+ *.iml
41
+ .idea/
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- fluent-plugin-logmatic
2
- ===============
1
+ # fluent-plugin-logmatic
3
2
 
4
3
  Fluentd output plugin for Logmatic.io.
5
4
 
@@ -7,20 +6,16 @@ It mainly contains a proper JSON formatter and a socket handler that
7
6
  streams logs directly to Logmatic.io - so no need to use a log shipper
8
7
  if you don't wan't to.
9
8
 
10
- Pre-requirements
11
- ================
9
+ ## Pre-requirements
12
10
 
13
11
  To add the plugin to your fluentd agent, use the following command:
14
12
 
15
13
  gem install fluent-plugin-logmatic
16
14
 
17
- Usage
18
- =====
15
+ ## Usage
16
+ ### Configure the output plugin
19
17
 
20
- "match" Tell fluentd how to send to Logmatic.io
21
- --------------------------
22
-
23
- To match events tagged logmatic, simply add the following code to your configuration file.
18
+ To match events and send them to logmatic.io, simply add the following code to your configuration file.
24
19
 
25
20
  ```xml
26
21
  # Match events tagged with "logmatic.**" and
@@ -32,49 +27,39 @@ To match events tagged logmatic, simply add the following code to your configura
32
27
 
33
28
  api_key <your_api_key>
34
29
 
30
+
35
31
  </match>
36
32
 
37
33
  ```
38
34
 
39
- Once this setup is done, any child events tagged with `logmatic` will be ship to your plateform.
35
+ After a restart of FluentD, any child events tagged with `logmatic` are shipped to your plateform.
40
36
 
37
+ ### Validation
41
38
  Let's make a simple test.
42
39
 
43
40
  ```bash
44
- echo '{"message":"hello world from fluentd"}' | fluent-cat logmatic.demo
41
+ echo '{"message":"hello Logmatic from fluentd"}' | fluent-cat logmatic.demo
45
42
  ```
46
43
 
47
- This will produce the following event:
44
+ Produces the following event:
48
45
 
49
46
  ```javascript
50
47
  {
51
- "custom": {
52
- "message": "hello world from fluentd"
48
+ "custom": {
49
+ "message": "hello Logmatic from fluentd"
53
50
  }
54
51
  }
55
52
  ```
56
53
 
57
- fluent-plugin-logmatic properties
58
- ======
59
- Let's go deeper on the plugin configuration.
54
+ ### fluent-plugin-logmatic properties
55
+ Let's go deeper on the plugin configuration.
60
56
 
61
57
  As fluent-plugin-logmatic is an output_buffer, you can set all output_buffer properties like it's describe in the [fluentd documentation](http://docs.fluentd.org/articles/output-plugin-overview#buffered-output-parameters "documentation").
62
58
 
63
- api_key
64
- --------
65
- This parameter is required in order to authenticate your fluent agent. The agent won't started until set your key.
66
-
67
- use_json
68
- --------
69
- If it's set to true, the event will be send to json format. If it's set to false, only the key `message` of the record will be sent to Logmatic.io. Set to true by default.
70
-
71
- use_ssl
72
- --------
73
- If it's set to true, the agent initialize a secure connection to Logmatic. Set to true by default.
74
-
75
-
76
- max_retries
77
- --------
78
- The number of retries before raised an error. By default, this parameter is set to 3.
79
-
80
59
 
60
+ | Property | Description | Default value |
61
+ |-------------|--------------------------------------------------------------------------|----------------|
62
+ | **api_key** | This parameter is required in order to authenticate your fluent agent. | nil |
63
+ | **use_json**| Event format, if true, the event is sent in json format. Othwerwise, in plain text. | true |
64
+ | **use_ssl** | If true, the agent initializes a secure connection to Logmatic.io. In clear TCP otherwise. | true |
65
+ |**max_retries**| The number of retries before the output plugin stops. Set to -1 for unlimited retries | -1 |
@@ -4,14 +4,14 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-logmatic"
7
- spec.version = "0.7"
7
+ spec.version = "0.8.1"
8
8
  spec.authors = ["Logmatic support team"]
9
9
  spec.email = ["support@logmatic.io"]
10
10
  spec.summary = "Logmatic output plugin for Fluent event collector"
11
- spec.homepage = "https://github.com/logmatic/fluent-plugin-logmatic"
11
+ spec.homepage = "http://logmatic.io"
12
12
  spec.license = "MIT"
13
13
 
14
- spec.files = `git ls-files -z`.split("\x0")
14
+ spec.files = [".gitignore", "Gemfile", "LICENSE", "README.md", "Rakefile", "fluent-plugin-logmatic.gemspec", "lib/fluent/plugin/out_logmatic.rb"]
15
15
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
@@ -6,7 +6,6 @@ class Fluent::LogmaticOutput < Fluent::BufferedOutput
6
6
 
7
7
  # Register the plugin
8
8
  Fluent::Plugin.register_output('logmatic', self)
9
-
10
9
  # Output settings
11
10
  config_param :use_json, :bool, :default => true
12
11
 
@@ -15,14 +14,22 @@ class Fluent::LogmaticOutput < Fluent::BufferedOutput
15
14
  config_param :use_ssl, :bool, :default => true
16
15
  config_param :port, :integer, :default => 10514
17
16
  config_param :ssl_port, :integer, :default => 10515
18
- config_param :max_retries, :integer, :default => 3
17
+ config_param :max_retries, :integer, :default => -1
19
18
 
20
19
  # API Settings
21
20
  config_param :api_key, :string
22
21
 
22
+ def initialize
23
+ super
24
+ end
25
+
26
+ # Define `log` method for v0.10.42 or earlier
27
+ unless method_defined?(:log)
28
+ define_method("log") { $log }
29
+ end
30
+
23
31
  def configure(conf)
24
32
  super
25
- @last_edit = Time.at(0)
26
33
  end
27
34
 
28
35
  def start
@@ -43,7 +50,14 @@ class Fluent::LogmaticOutput < Fluent::BufferedOutput
43
50
  else
44
51
  TCPSocket.new @host, @port
45
52
  end
46
-
53
+
54
+ @_socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
55
+ @_socket.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPIDLE, 10)
56
+ @_socket.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPINTVL, 3)
57
+ @_socket.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPCNT, 3)
58
+
59
+ return @_socket
60
+
47
61
  end
48
62
 
49
63
  # This method is called when an event reaches Fluentd.
@@ -54,31 +68,47 @@ class Fluent::LogmaticOutput < Fluent::BufferedOutput
54
68
  # NOTE! This method is called by internal thread, not Fluentd's main thread.
55
69
  # 'chunk' is a buffer chunk that includes multiple formatted events.
56
70
  def write(chunk)
57
-
71
+
72
+ messages = Array.new
58
73
  chunk.msgpack_each do |tag, record|
59
74
  next unless record.is_a? Hash
60
75
  next unless @use_json or record.has_key? "message"
61
- message = @use_json ? record.to_json : record["message"].rstrip()
62
- send_to_logmatic(message)
76
+ if @use_json
77
+ messages.push "#{api_key} " + record.to_json + "\n"
78
+ else
79
+ messages.push "#{api_key} " + record["message"].rstrip() + "\n"
80
+ end
63
81
  end
82
+ send_to_logmatic(messages)
64
83
 
65
84
  end
66
85
 
67
86
  def send_to_logmatic(data)
68
87
 
88
+
69
89
  retries = 0
70
90
 
71
91
  begin
72
92
 
73
- client.write("#{api_key} #{data}\n")
93
+ # Check the connectivity and write messages
94
+ #connected,x = client.recv(0)
95
+ #log.trace "Connected=#{connected},#{x}"
96
+ #raise Errno::ECONNREFUSED, "Client has lost server connection" if connected == 0
97
+ log.trace "New attempt to Logmatic attempt=#{retries}" if retries > 0
98
+ log.trace "Send nb_event=#{data.size} events to Logmatic"
99
+ data.each do |event|
100
+ client.write(event)
101
+ end
102
+
74
103
 
75
104
  # Handle some failures
76
- rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT, Errno::EPIPE => e
105
+ rescue Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Errno::EPIPE => e
77
106
 
78
- if retries < @max_retries
79
- retries += 1
107
+ if retries < @max_retries || max_retries == -1
80
108
  @_socket = nil
81
- a_couple_of_seconds = 5**retries
109
+ a_couple_of_seconds = retries ** 2
110
+ a_couple_of_seconds = 30 unless a_couple_of_seconds < 30
111
+ retries += 1
82
112
  log.warn "Could not push logs to Logmatic, attempt=#{retries} max_attempts=#{max_retries} wait=#{a_couple_of_seconds}s error=#{e.message}"
83
113
  sleep a_couple_of_seconds
84
114
  retry
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-logmatic
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.7'
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Logmatic support team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-03 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ files:
52
52
  - Rakefile
53
53
  - fluent-plugin-logmatic.gemspec
54
54
  - lib/fluent/plugin/out_logmatic.rb
55
- homepage: https://github.com/logmatic/fluent-plugin-logmatic
55
+ homepage: http://logmatic.io
56
56
  licenses:
57
57
  - MIT
58
58
  metadata: {}
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  version: '0'
73
73
  requirements: []
74
74
  rubyforge_project:
75
- rubygems_version: 2.5.1
75
+ rubygems_version: 2.6.1
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: Logmatic output plugin for Fluent event collector