fluent-plugin-prometheus 1.8.0 → 1.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
  SHA256:
3
- metadata.gz: 3f98778420f98da85a1325661e897dce930a9eaec03675f3112ca9223a8435a4
4
- data.tar.gz: 864fd85893d2cbe49c2aa5d8e59026405098d9075e54499cbe3efc8e30025a3d
3
+ metadata.gz: f48e673585638a68fa128172db768d7f35035a04f4d55bb98737e7cfd5d7cdf2
4
+ data.tar.gz: 1030ddd92d55c5e6603e49933760eadac266f5081cbb54169b0ebc237bcfe933
5
5
  SHA512:
6
- metadata.gz: ae6ec1075cf1fa4ab375a888c0a37c2653cf067e25a87b588ef5b5a332aa090cb1794b9add155314e4b867a188cca55450b064ea04ec99cb9299ad2fcfbde37b
7
- data.tar.gz: c0d269902c7efff6fe7cb153c853fc17eaf9b0a740994ece3701854308fff45af2fa906c17efa2d0af32f882dfdcdd40340c5f3b8ad21a58469655104064a0c1
6
+ metadata.gz: adb129f3a83c6be98247e2180d6cb26037a1e8e32e10c555232cf9d267867b4b5b6d5168adebbb9b8ed16b1193c9ff7e8879b379ccb92406b66cb2abc67075e1
7
+ data.tar.gz: 2e7a8eecf131d31d08266507620939f7f9b73613d39009d6c2349bbb166b778dae82baa6ea84021793b5374c1372b5cd0673b126ec5b6981c9dfd368c8da0922
@@ -0,0 +1,11 @@
1
+ Release 1.8.1 - 2020/07/06
2
+
3
+ * Fix aggregate bug with async-http
4
+
5
+ Release 1.8.0 - 2020/04/17
6
+
7
+ * Use http_server helper
8
+ * Require fluentd v1.9.1 or later
9
+
10
+
11
+ For older releases, see commits on github repository.
data/README.md CHANGED
@@ -124,7 +124,7 @@ Metrics for output
124
124
  - `fluentd_output_status_emit_records`
125
125
  - `fluentd_output_status_write_count`
126
126
  - `fluentd_output_status_rollback_count`
127
- - `fluentd_output_status_flush_time_count` from fluentd v1.6.0
127
+ - `fluentd_output_status_flush_time_count` in milliseconds from fluentd v1.6.0
128
128
  - `fluentd_output_status_slow_flush_count` from fluentd v1.6.0
129
129
 
130
130
  Metrics for buffer
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "fluent-plugin-prometheus"
3
- spec.version = "1.8.0"
3
+ spec.version = "1.8.1"
4
4
  spec.authors = ["Masahiro Sano"]
5
5
  spec.email = ["sabottenda@gmail.com"]
6
6
  spec.summary = %q{A fluent plugin that collects metrics and exposes for Prometheus.}
@@ -73,6 +73,14 @@ module Fluent::Plugin
73
73
  return
74
74
  end
75
75
 
76
+ begin
77
+ require 'async'
78
+ require 'fluent/plugin/in_prometheus/async_wrapper'
79
+ extend AsyncWrapper
80
+ rescue LoadError => _
81
+ # ignore
82
+ end
83
+
76
84
  tls_opt = if @ssl && @ssl['enable']
77
85
  ssl_config = {}
78
86
 
@@ -185,7 +193,7 @@ module Fluent::Plugin
185
193
  full_result = PromMetricsAggregator.new
186
194
 
187
195
  send_request_to_each_worker do |resp|
188
- if resp.is_a?(Net::HTTPSuccess)
196
+ if resp.code.to_s == '200'
189
197
  full_result.add_metrics(resp.body)
190
198
  end
191
199
  end
@@ -197,14 +205,14 @@ module Fluent::Plugin
197
205
 
198
206
  def send_request_to_each_worker
199
207
  bind = (@bind == '0.0.0.0') ? '127.0.0.1' : @bind
200
- req = Net::HTTP::Get.new(@metrics_path)
201
208
  [*(@base_port...(@base_port + @num_workers))].each do |worker_port|
202
209
  do_request(host: bind, port: worker_port, secure: @secure) do |http|
203
- yield(http.request(req))
210
+ yield(http.get(@metrics_path))
204
211
  end
205
212
  end
206
213
  end
207
214
 
215
+ # might be replaced by AsyncWrapper if async gem is installed
208
216
  def do_request(host:, port:, secure:)
209
217
  http = Net::HTTP.new(host, port)
210
218
 
@@ -214,7 +222,7 @@ module Fluent::Plugin
214
222
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
215
223
  end
216
224
 
217
- http.start do
225
+ http.start do
218
226
  yield(http)
219
227
  end
220
228
  end
@@ -0,0 +1,46 @@
1
+ require 'async'
2
+
3
+ module Fluent::Plugin
4
+ class PrometheusInput
5
+ module AsyncWrapper
6
+ def do_request(host:, port:, secure:)
7
+ endpoint =
8
+ if secure
9
+ context = OpenSSL::SSL::SSLContext.new
10
+ context.verify_mode = OpenSSL::SSL::VERIFY_NONE
11
+ Async::HTTP::Endpoint.parse("https://#{host}:#{port}", ssl_context: context)
12
+ else
13
+ Async::HTTP::Endpoint.parse("http://#{host}:#{port}")
14
+ end
15
+
16
+ client = Async::HTTP::Client.new(endpoint)
17
+ yield(AsyncHttpWrapper.new(client))
18
+ end
19
+
20
+ Response = Struct.new(:code, :body, :headers)
21
+
22
+ class AsyncHttpWrapper
23
+ def initialize(http)
24
+ @http = http
25
+ end
26
+
27
+ def get(path)
28
+ error = nil
29
+ response = Async::Task.current.async {
30
+ begin
31
+ @http.get(path)
32
+ rescue => e # Async::Reactor rescue all error. handle it by itself
33
+ error = e
34
+ end
35
+ }.wait
36
+
37
+ if error
38
+ raise error
39
+ end
40
+
41
+ Response.new(response.status.to_s, response.body.read, response.headers)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-prometheus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Sano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-21 00:00:00.000000000 Z
11
+ date: 2020-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -110,6 +110,7 @@ files:
110
110
  - ".gitignore"
111
111
  - ".rspec"
112
112
  - ".travis.yml"
113
+ - ChangeLog
113
114
  - Gemfile
114
115
  - LICENSE
115
116
  - README.md
@@ -117,6 +118,7 @@ files:
117
118
  - fluent-plugin-prometheus.gemspec
118
119
  - lib/fluent/plugin/filter_prometheus.rb
119
120
  - lib/fluent/plugin/in_prometheus.rb
121
+ - lib/fluent/plugin/in_prometheus/async_wrapper.rb
120
122
  - lib/fluent/plugin/in_prometheus_monitor.rb
121
123
  - lib/fluent/plugin/in_prometheus_output_monitor.rb
122
124
  - lib/fluent/plugin/in_prometheus_tail_monitor.rb