fluent-plugin-logzio 0.0.13 → 0.0.14

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: cb60223d1da3b7dcbb52f07e9094c2d62e4eef64
4
- data.tar.gz: 61edf950ff5231802cd82615207cf3d5f43bdf63
3
+ metadata.gz: 88fbcbf908f73177e386858478a979f45beb63c5
4
+ data.tar.gz: bd27f0a066852955f52414197d72d6be87f6e023
5
5
  SHA512:
6
- metadata.gz: e9e3307a7108db15a6ed7f66171993580fcac951716a1f559b0495a2377a132c635cc78400e2c1f74843a92fad3f62cc6acb70a579706d95a0a84df379796b9e
7
- data.tar.gz: 5d1bbc1043da77fd3642e620c0490727c27d4d0546c64af633d2c87393772b5c4ac13195d37596bda3c214f790c3a124d4aa46a2fd3c644b0cf846b9367c98a7
6
+ metadata.gz: 597e9edb06b3aad61358d49541bb69405e5c6b4f2853ef7ed2bdc08f356b5e1642675a82c1628cba32b77bd37715ae95c5d97ad298588a165b8b1ae779f8c081
7
+ data.tar.gz: b423b45d6d6749c6dbe480511e8ba0bda2d1dda126c4c006d23c3e47fdc39b3f278f98f07d029a7675485bf56792a7b24bae04e627cc25eb75f4c1b05f1611e9
data/README.md CHANGED
@@ -33,5 +33,6 @@ With fluent-plugin-logzio you will be able to use [Logz.io](http://logz.io) as o
33
33
 
34
34
 
35
35
  ## Release Notes
36
+ - 0.0.14: Refactor send function to handle more cases, and retry in case of logzio connection failure
36
37
  - 0.0.13: BREAKING - Removed non-buffered version. It's really not efficient, and should just not be used. If you are using this version, you should change to the buffered one.
37
38
  - 0.0.12: Catch exception when parsing YAML to ignore (instead of crash) not valid logs
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'fluent-plugin-logzio'
7
- s.version = '0.0.13'
7
+ s.version = '0.0.14'
8
8
  s.authors = ['Yury Kotov', 'Roi Rav-Hon']
9
9
  s.email = ['bairkan@gmail.com', 'roi@logz.io']
10
10
  s.homepage = 'https://github.com/logzio/fluent-plugin-logzio'
@@ -4,7 +4,7 @@ module Fluent
4
4
  config_param :endpoint_url, :string, default: nil
5
5
  config_param :output_include_time, :bool, default: true
6
6
  config_param :output_include_tags, :bool, default: true
7
- config_param :retry_count, :integer, default: 3 # How many times to resend failed bulks. Undocumented because not suppose to be changed
7
+ config_param :retry_count, :integer, default: 4 # How many times to resend failed bulks. Undocumented because not suppose to be changed
8
8
  config_param :http_idle_timeout, :integer, default: 5
9
9
  config_param :output_tags_fieldname, :string, default: 'fluentd_tags'
10
10
 
@@ -57,50 +57,44 @@ module Fluent
57
57
  # Logz.io bulk http endpoint expecting log line with \n delimiter
58
58
  post.body = records.join("\n")
59
59
 
60
- begin
61
- response = @http.request @uri, post
62
- should_retry = true
63
-
64
- if response.code != '200'
65
- if response.code == '401'
66
- log.error("You are not authorized with Logz.io! Token OK? dropping logs...")
67
- should_retry = false
68
- end
60
+ sleep_interval = 2
69
61
 
70
- if response.code == '400'
71
- log.info("Got 400 code from Logz.io. This means that some of your logs are too big, or badly formatted. Response: #{response.body}")
72
- should_retry = false
62
+ begin
63
+ @retry_count.times do |counter|
64
+ should_retry = true
65
+ begin
66
+ response = @http.request @uri, post
67
+ if response.code != '200'
68
+ if response.code == '401'
69
+ log.error "You are not authorized with Logz.io! Token OK? dropping logs..."
70
+ should_retry = false
71
+ elsif response.code == '400'
72
+ log.info "Got 400 code from Logz.io. This means that some of your logs are too big, or badly formatted. Response: #{response.body}"
73
+ should_retry = false
74
+ else
75
+ log.debug "Got HTTP #{response.code} from logz.io, not giving up just yet (Try #{counter + 1}/#{@retry_count})"
76
+ end
77
+ else
78
+ log.debug "Successfuly sent bulk"
79
+ should_retry = false
80
+ end
81
+ rescue StandardError => e
82
+ log.debug "Error connecting to logzio. Got exception: #{e} (Try #{counter + 1}/#{@retry_count})"
73
83
  end
74
84
 
75
- # If any other non-200 or 400/401, we will try to resend it after 2, 4 and 8 seconds. Then we will give up
76
- sleep_interval = 2
77
-
78
85
  if should_retry
79
- log.debug "Got HTTP #{response.code} from logz.io, not giving up just yet"
80
- @retry_count.times do |counter|
81
- log.debug "Sleeping for #{sleep_interval} seconds, and trying again."
82
- sleep(sleep_interval)
83
-
84
- # Retry
85
- response = @http.request @uri, post
86
-
87
- # Sucecss, no further action is needed
88
- if response.code == 200
89
- log.debug "Successfuly sent the failed bulk."
90
- break
91
- else
92
- # Doubling the sleep interval
93
- sleep_interval *= 2
94
-
95
- if counter == @retry_count - 1
96
- log.error "Could not send your bulk after 3 tries. Sorry. Got HTTP #{response.code} with body: #{response.body}"
97
- end
98
- end
86
+ if counter == @retry_count - 1
87
+ log.error "Could not send your bulk after #{retry_count} tries. Sorry."
88
+ break
99
89
  end
90
+ sleep(sleep_interval)
91
+ sleep_interval *= 2
92
+ else
93
+ return
100
94
  end
101
95
  end
102
- rescue StandardError => error
103
- log.error "Error connecting to logzio. Got exception: #{error}"
96
+ rescue Exception => e
97
+ log.error "Got unexpected exception! Here: #{e}"
104
98
  end
105
99
  end
106
100
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-logzio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Kotov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-08-10 00:00:00.000000000 Z
12
+ date: 2017-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-http-persistent