fluent-plugin-prometheus 1.0.1 → 1.1.0

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
- SHA1:
3
- metadata.gz: 2a57fd10632488d41ca2f4fd29de81b238e35ca8
4
- data.tar.gz: 2008368dbac8114bf331f4b35171f23fea3d0224
2
+ SHA256:
3
+ metadata.gz: bc058ef050bbdee33044783899fc6af14b731d974cb5f2b827997683a82ddb85
4
+ data.tar.gz: aef907fc671770e55a4fb1cad4de41b09c6a0b053b6fbcc5fbde8193d71faa0d
5
5
  SHA512:
6
- metadata.gz: 5ce7f491f1f8528f6da19b0d20eff61a0c48fa76b082d83b8a3fdcf9493355a9def2ba5dccbb07941348a0d2ef0c34a8602f002e7e02f2109df6737414f7c3c1
7
- data.tar.gz: ed7d1d932ecc7a498279cb836860633a51916e910f315addcb3c42519ed2f3aede977871959eaebb731b3725842a88905fd628dd633477e976f545cab86185b6
6
+ metadata.gz: 4888508f00beb7f8654e7139f1d26962e1f3a2193b81a97b4f874a61d82ea759bde7f14558fba123565a01758478d6e30aad46937e7715bed8489099424579de
7
+ data.tar.gz: ea29389ae6b63bf8a8f20124d7cd8651f88dbe45db66e40a74eecc2ce73762f400385ae73adf8074a2e8733cb132340233f282cb1d27aecfb627fbdd7e9bd468
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - "2.3.4"
5
- - "2.4.1"
4
+ - "2.3.6"
5
+ - "2.4.3"
6
+ - "2.5.0"
6
7
 
7
8
  gemfile:
8
9
  - Gemfile
data/README.md CHANGED
@@ -73,9 +73,11 @@ Current exposed metrics:
73
73
 
74
74
  With following configuration, those metrics are collected.
75
75
 
76
+ ```
76
77
  <source>
77
78
  @type prometheus_monitor
78
79
  </source>
80
+ ```
79
81
 
80
82
  More configuration parameters:
81
83
 
@@ -107,9 +109,11 @@ Current exposed metrics:
107
109
 
108
110
  With following configuration, those metrics are collected.
109
111
 
112
+ ```
110
113
  <source>
111
114
  @type prometheus_output_monitor
112
115
  </source>
116
+ ```
113
117
 
114
118
  More configuration parameters:
115
119
 
@@ -139,9 +143,11 @@ Default labels:
139
143
 
140
144
  With following configuration, those metrics are collected.
141
145
 
146
+ ```
142
147
  <source>
143
148
  @type prometheus_tail_monitor
144
149
  </source>
150
+ ```
145
151
 
146
152
  More configuration parameters:
147
153
 
@@ -340,9 +346,10 @@ Reserved placeholders are:
340
346
  - `${hostname}`: hostname
341
347
  - `${worker_id}`: fluent worker id
342
348
  - `${tag}`: tag name
349
+ - only availabe in prometheus output/filter plugin
343
350
 
344
351
 
345
- ### top-label labels and labels inside metric
352
+ ### top-level labels and labels inside metric
346
353
 
347
354
  Prometheus output/filter plugin can have multiple metric section. Top-level labels section spcifies labels for all metrics. Labels section insede metric section specifis labels for the metric. Both are specified, labels are merged.
348
355
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "fluent-plugin-prometheus"
3
- spec.version = "1.0.1"
3
+ spec.version = "1.1.0"
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.}
@@ -12,6 +12,23 @@ module Fluent::Plugin
12
12
  config_param :port, :integer, default: 24231
13
13
  config_param :metrics_path, :string, default: '/metrics'
14
14
 
15
+ desc 'Enable ssl configuration for the server'
16
+ config_section :ssl, required: false, multi: false do
17
+ config_param :enable, :bool, default: false
18
+
19
+ desc 'Path to the ssl certificate in PEM format. Read from file and added to conf as "SSLCertificate"'
20
+ config_param :certificate_path, :string, default: nil
21
+
22
+ desc 'Path to the ssl private key in PEM format. Read from file and added to conf as "SSLPrivateKey"'
23
+ config_param :private_key_path, :string, default: nil
24
+
25
+ desc 'Path to CA in PEM format. Read from file and added to conf as "SSLCACertificateFile"'
26
+ config_param :ca_path, :string, default: nil
27
+
28
+ desc 'Additional ssl conf for the server. Ref: https://github.com/ruby/webrick/blob/master/lib/webrick/ssl.rb'
29
+ config_param :extra_conf, :hash, default: {:SSLCertName => [['CN','nobody'],['DC','example']]}, symbolize_keys: true
30
+ end
31
+
15
32
  attr_reader :registry
16
33
 
17
34
  def initialize
@@ -30,15 +47,40 @@ module Fluent::Plugin
30
47
 
31
48
  def start
32
49
  super
33
-
34
50
  log.debug "listening prometheus http server on http://#{@bind}:#{@port}/#{@metrics_path} for worker#{fluentd_worker_id}"
35
- @server = WEBrick::HTTPServer.new(
51
+ config = {
36
52
  BindAddress: @bind,
37
53
  Port: @port,
38
54
  MaxClients: 5,
39
55
  Logger: WEBrick::Log.new(STDERR, WEBrick::Log::FATAL),
40
56
  AccessLog: [],
41
- )
57
+ }
58
+ unless @ssl.nil? || !@ssl['enable']
59
+ require 'webrick/https'
60
+ require 'openssl'
61
+ if (@ssl['certificate_path'] && @ssl['private_key_path'].nil?) || (@ssl['certificate_path'].nil? && @ssl['private_key_path'])
62
+ raise RuntimeError.new("certificate_path and private_key_path most both be defined")
63
+ end
64
+ ssl_config = {
65
+ SSLEnable: true
66
+ }
67
+ if @ssl['certificate_path']
68
+ cert = OpenSSL::X509::Certificate.new(File.read(@ssl['certificate_path']))
69
+ ssl_config[:SSLCertificate] = cert
70
+ end
71
+ if @ssl['private_key_path']
72
+ key = OpenSSL::PKey::RSA.new(File.read(@ssl['private_key_path']))
73
+ ssl_config[:SSLPrivateKey] = key
74
+ end
75
+ ssl_config[:SSLCACertificateFile] = @ssl['ca_path'] if @ssl['ca_path']
76
+ ssl_config = ssl_config.merge(@ssl['extra_conf'])
77
+ config = ssl_config.merge(config)
78
+ end
79
+ @log.on_debug do
80
+ @log.debug("WEBrick conf: #{config}")
81
+ end
82
+
83
+ @server = WEBrick::HTTPServer.new(config)
42
84
  @server.mount(@metrics_path, MonitorServlet, self)
43
85
  thread_create(:in_prometheus) do
44
86
  @server.start
@@ -69,7 +69,7 @@ module Fluent::Plugin
69
69
  tails = info['instance_variables'][:tails]
70
70
  next if tails.nil?
71
71
 
72
- tails.each do |_, watcher|
72
+ tails.clone.each do |_, watcher|
73
73
  # Access to internal variable of internal class...
74
74
  # Very fragile implementation
75
75
  pe = watcher.instance_variable_get(:@pe)
@@ -60,6 +60,7 @@ module Fluent
60
60
  placeholder_values = {
61
61
  'tag' => tag,
62
62
  'hostname' => @hostname,
63
+ 'worker_id' => fluentd_worker_id,
63
64
  }
64
65
 
65
66
  es.each do |time, record|
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.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Sano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-18 00:00:00.000000000 Z
11
+ date: 2018-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  requirements: []
153
153
  rubyforge_project:
154
- rubygems_version: 2.6.13
154
+ rubygems_version: 2.7.6
155
155
  signing_key:
156
156
  specification_version: 4
157
157
  summary: A fluent plugin that collects metrics and exposes for Prometheus.